#include
#include
#include
struct Node
{
char data;
struct Node *lchild, *rchild;
};
int CreateBiTree(struct Node *T)
{
char ch;
scanf("%c", &ch);
if(ch=='#')
T=NULL;
else{
T=(struct Node *)malloc(sizeof(struct Node));
if(!T)
exit(-1);
T->data=ch;
CreateBiTree(T->lchild);
CreateBiTree(T->rchild);
}
return 0;
}
int PreOrder(struct Node *T)
{
if(T){
printf("%c", T->data);
PreOrder(T->lchild);
PreOrder(T->rchild);
}
return 0;
}
int main()
{
struct Node *T;
CreateBiTree(T);
PreOrder(T);
}
输入停止不了,处于无限输入状态
不知道该怎样该,请大神指教