|
#include<iostream>
#include<string>
using namespace std;
string z,c;
void x(int zf,int zt,int cf,int ct){
bool b = 0;
int root;
for(int i = cf;i<=ct;i++){
b = 0;
for(int j = zf;j<=zt;j++){
if(z[j] == c){
b = 1;
root = j;
break;
}
}
if(b == 1){
break;
}
}
cout<<z[root];
if(root>zf){
x(zf,root-1,cf,ct);
}
if(root<zt){
x(root+1,zt,cf,ct);
}
}
int main(){
cin>>z>>c;
x(0,z.size()-1,0,c.size()-1);
return 0;
}
|
|