标签:
D / / B E / \ / \ A C G / / F
DBACEGF ABCDEFG BCAD CBAD
ACBFGED CDAB
解题思路:跟这个题是一样的
#include <iostream> #include <cstdio> #include <cstring> using namespace std; char pre[30]; char in[30]; void subsquent(int s1,int s2,int n){ if(n==1){ printf("%c",pre[s1]); } if(n<=1){ return ; } int i; for(i=0;pre[s1]!=in[s2+i];i++); subsquent(s1+1,s2,i); subsquent(s1+i+1,s2+i+1,n-i-1); printf("%c",pre[s1]); } int main() { while(scanf("%s %s",pre+1,in+1)!=EOF){ int n=strlen(pre+1); subsquent(1,1,n); printf("\n"); } return 0; }
nyoj221_Tree_subsequent_traversal
标签:
原文地址:http://www.cnblogs.com/TWS-YIFEI/p/5822602.html