NYOJ-221 Tree
01. 02.#include
"iostream"03.#include
"cstdio"04.#include
"cstdlib"05.#include
"cstring"06. 07.using namespace std;08. 09.typedef struct TreeNode10.{11. char e;12. struct TreeNode * lchild, *rchild;13.}TreeNode,*Tree;14.23.void SwitchPost(char
* In, char * Pre,
int len)24.{25. if(len == 0) return;26. char r = Pre[0];27. int root = 0;28. for(;root29. {30. if(In[root] == Pre[0] ) break;31. }32. SwitchPost(In,Pre+1,root);33. SwitchPost(In+root+1, Pre+root+1,
len-root-1);34. printf("%c",r);35. return;36.}37.int main()38.{39. char In[27],Pre[27];40. while(scanf("%s%s",Pre,In)!=EOF)41. {42. //puts(Pre);puts(In);43. int len = strlen(Pre);44. char *I = In;45. char *P = Pre;46. //puts(Pre);puts(In);cout<<"len="<<len<<endl;47. SwitchPost(In,Pre,len);48. printf("\n");49. }50. return 0;51.}