标签:
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 4330 Accepted Submission(s): 1970
#include<stdio.h> #include<string.h> int str1[1005],str2[1005],str3[1005]; int sum; int getlen(int root,int str2[]){ int cnt=0; int i=0; while(1){ if(str2[i]==root) return cnt; i++; cnt++; } } void change(int m,int str1[],int str2[]){ if(m==0) return ; int len=getlen(str1[0],str2); change(len,str1+1,str2); change(m-1-len,str1+1+len,str2+len+1); str3[++sum]=str1[0]; } int main(){ int n; while(scanf("%d",&n)!=EOF){ sum=-1; memset(str1,0,sizeof(str1)); memset(str2,0,sizeof(str2)); memset(str3,0,sizeof(str3)); for(int i=0;i<n;i++) scanf("%d",&str1[i]); for(int i=0;i<n;i++) scanf("%d",&str2[i]); change(n,str1,str2); for(int i=0;i<n;i++) printf("%d%c",str3[i],i==n-1?‘\n‘:‘ ‘); } return 0; }
HDU 1710 二叉树的遍历 Binary Tree Traversals
标签:
原文地址:http://www.cnblogs.com/13224ACMer/p/4669101.html