hiho Week 10 register

Ended

Participants:639

Verdict:Accepted
Score:100 / 100
Submitted:2014-09-08 00:06:37

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include<iostream>
#include<string>
using namespace std;
string s1,s2;
string getresult(int begin1,int begin2, int len){
    int i;
    if(len<=0)
        return "";
    for(i=begin2;i<begin2+len;i++){
        if(s2[i]==s1[begin1])
            break;
    }
    int l=i-begin2;
    string a1=getresult(begin1+1,begin2,l);
    string a2=getresult(begin1+l+1,i+1,len-l-1);
    return a1+a2+s1[begin1];
}
int main(){
    cin>>s1>>s2;
    int l=s1.length();
    cout<<getresult(0,0,l);
    return 0;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX