摘要:
int cmptime(char *p,char *q,int n){ int times=0,i; int lenp=strlen(p); int lenq=strlen(q); if(lenp<n||lenq<n) return 0; char *tq=q; while(lenq>=n) { for(i=0;i<n;i++) { if(p[i]!=tq[i]) break; } if(i<n) return times; else { times++; tq=tq+n; lenq=lenq-n; } } return times;}int lgstrtime( 阅读全文
摘要:
a b d f g e h i c k j: 前序f d g b h e i a k c j:中序0 1 2 3 4 5 6 7 8 9 10用前序的首字母 将中序分割成两段 分别对应左右子树关键在于如何得到这两段 很简单 :在中序里 a的序号为7,从而0-7 为左子树,这一段相应在前序中序号为 1-8(前点虽然不同,但长度相同) b d f g e h i : 前序f d g b h e i :中序char post[1000];char pre[1000];char mid[1000];int getroot(char r){ int i=0; while(mid[i]!='\0& 阅读全文