帮忙看一下我的这个扩展先序遍历序列建立二叉树的程序代码哪儿有错误:

来源:百度知道 编辑:UC知道 时间:2024/07/03 11:28:15
typedef struct Node
{
char data;
struct Node * Lchild;
struct Node * Rchild;
}BiTNode,*BiTree;

// 扩展先序遍历序列建立二叉树

void CreateBiTree(BiTree *bt)
{
char ch;
printf("请输入单个字符:\n");
scanf("%c",&ch);
if(ch=='.')
*bt=NULL;
else
{
*bt=(BiTree)malloc(sizeof(BiTNode));
(*bt)->data=ch;
CreateBiTree(&((*bt)->Lchild));
CreateBiTree(&((*bt)->Rchild));
}
}

void CreateBiTree(BiTree &bt) //第一处:应该传递地址,要不调用返回后,bt什么也没有(带//的都需要改)
{
char ch;
printf("请输入单个字符:\n");
scanf("%c",&ch);
if(ch==' ') //空的
bt=NULL; //
else
{
bt=(BiTree *)malloc(sizeof(BiTNode)); //
bt->data=ch;//
CreateBiTree(bt->Lchild); //
CreateBiTree(bt->Rchild); //
}
}