题目:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=1291
以前的一个题,贴下代码;
1 #include<stdio.h> 2 #include<string.h> 3 char ans[100]; 4 5 void build(int n, char *s1, char *s2, char *s) 6 { 7 if(n <= 0) return; 8 int p = strchr(s2, s1[0])-s2; 9 build(p, s1+1, s2, s); 10 build(n-p-1, s1+p+1, s2+p+1, s+p); 11 s[n-1]=s1[0];//将根节点添加到最后 12 }; 13 14 int main() 15 { 16 int k,t; 17 char s1[100], s2[100]; 18 gets(s1); 19 gets(s2); 20 k=strlen(s1); 21 build(k, s1, s2,ans); 22 printf("%s\n",ans); 23 return 0; 24 }
来源:https://www.cnblogs.com/bfshm/p/3166010.html