#include<bits/stdc++.h>
using namespace std;
typedef struct node * tree;
typedef struct node
{
tree rchild;
tree lchild;
char data;
}node;
tree dfs(char *in,char *pre,int length)
{
if(length<=0)
return NULL;
tree t=new node;
int root=0;
t->data=*pre;
for(;root<length;root++)
{
if(in[root]==*pre)
{
break;
}
}
t->lchild=dfs(in,pre+1,root);
t->rchild=dfs(in+root+1,pre+root+1,length-root-1);
cout<<t->data;
return t;
}
int main()
{
char in[27],pre[27];
while(cin>>pre>>in)
{
dfs(in,pre,strlen(in));
cout<<endl;
}
return 0;
}
紫书UVA 536
最新推荐文章于 2021-03-04 14:56:10 发布