- 9
- 0
- 约1.94千字
- 约 5页
- 2018-06-27 发布于河南
- 举报
二叉树基本操作及实现的程序(完全正确)
#includeiostream
#includeconio.h
using namespace std;
typedef struct BiTNode
{
char data;
struct BiTNode* lchild;
struct BiTNode* rchild;
}Bitnode,*BiTree;
BiTree createbintree()
{
BiTree t;
char x;
// scanf(%c,x);
cinx;
if(x==#)
t=NULL;
else
{
// t=(BTNode*)malloc(sizeof(BTNode));
t=new Bitnode;
t-data=x;
cout请输入x的左子树(若无请输入#):;
t-lchild=createbintree();
cout请输入x的右子树(若无请输入#):;
t-rchild=createbintree();
}
return(t);
}
void Insert(BiTree t, char data){
BiTree s;
if (t==NULL)/*递归结束条件*/
{
s=new Bitnode;
s-data=data;
s-lchild=NULL;
s-rchild=NULL;
t=s;
}
else
if
原创力文档

文档评论(0)