const int maxn=105;char s1[maxn],s2[maxn],s[maxn];//s1为先序遍历结果,s2为中序遍历结果,s为后续遍历结果void build(int n,char *s1,char *s2,char *s) //n为字符串长度{ if(n<=0) return ; int p = strchr(s2,s1[0])-s2; build(p,s1+1,s2,s); build(n-1-p,s1+p+1,s2+p+1,s+p); s[n-1] = s1[0];}/*在main函数里加句s[n]='/0';*/
新闻热点
疑难解答