文章
17
粉丝
0
获赞
5
访问
1.3k
#include<iostream>
#include<string>
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;
//二叉树结构
typedef struct node{
char data;
struct node *lchild,*rchild;
}*BiTree;
//先序遍历的方式建立二叉树
void CreateBiTree(BiTree &T,const string &s,int &index){
if(index<s.length()){
char ch=s[index++];
if(ch=='0') T=NULL;
else{
T=new node;
T->data=ch;
CreateBiTree(T->lchild,s,index);
CreateBiTree(T->rchild,s,index);
}
}
&nb...
登录后发布评论
暂无评论,来抢沙发