文章
82
粉丝
344
获赞
28
访问
698.2k
#include<iostream>
#include<queue>
#include<string>
#include<string.h>
using namespace std;
typedef struct node{
char data;
struct node*lchild;
struct node*rchild;
}BiNode,*BiTree;
int m,n;
char pre[27];
char mid[27];
char post[27];
BiTree build(char *pre,char *mid,int l1,int r1,int l2,int r2){
if(l1>r1) return NULL;//递归边界
int flag=0;
for(int i=l2;i<=r2;i++){
if(mid[i]==pre[l1]){
flag=i;
break;
}
}
BiTree t=new node;
t->data=pre[l1];
t->lchild=t->rchild=NULL;
t->lchild=build(pre,mid,l1+1,l1+flag-l2,l2,flag-1);
 ...
登录后发布评论
暂无评论,来抢沙发