文章
17
粉丝
0
获赞
5
访问
1.3k
#include<iostream>
using namespace std;
typedef struct node{
char data;
struct node *lchild,*rchild;
}*BitTree;
//先序遍历的方式创建二叉树
//常量引用不会修改s的原值,普通引用会修改原值所用index会变
void CreateBitTree(BitTree &T,const string &s,int &index){
//超过字符串长度就退出
if(index>=s.length()){
T=NULL;
return;
}
char ch=s[index++];
//#当作空节点
if(ch=='#'){
T=NULL;
}
//非空节点插入
else{
T=new node;
T->data=ch;
CreateBitTree(T->lchild,s,in...
登录后发布评论
暂无评论,来抢沙发