求指教
代码没有报错,但是运行的时候就打印了一段文字,之后怎么输入都没有反应了……
以下是代码要实现的功能:

以下是我的代码:
#include
#include
#define OVERFLOW 0
#define MAXSIZE 100
typedef struct BiTNode
{
char data;
struct BiTNode *lchild,*rchild;
}BiTNode,*BiTree;
void CreateBT(BiTree &T)
{
char c;
c=getchar();
if(!(T=(BiTNode*)malloc(sizeof(BiTNode))))
exit(OVERFLOW);
T->data=c;
if(c=='#')
goto L1;
if(!(T->lchild=(BiTNode*)malloc(sizeof(BiTNode))))
exit(OVERFLOW);
CreateBT(T->lchild);
if(!(T->rchild=(BiTNode*)malloc(sizeof(BiTNode))))
exit(OVERFLOW);
CreateBT(T->rchild);
L1:;
}
void ExchangeBT(BiTree T)
{
BiTree t=NULL;
t=T->lchild;
T->lchild=T->rchild;
T->rchild=t;
ExchangeBT(T->lchild);
ExchangeBT(T->rchild);
}
BiTree SearchBT(BiTree T,char e)
{
BiTree t;
t->data=NULL;
t->lchild=NULL;
t->rchild=NULL;
if(T->data==e)
return T;
else if(T->data=='#')
{
printf("您查找的结点不存在");
return t;
}
else
{
SearchBT(T->lchild,e);
SearchBT(T->rchild,e);
}
}
void CountBT(BiTree T,int &d0,int &d1,int &d2)
{
if(T->data!='*')
{ if(T->lchild->data=='*'&&T->rchild->data=='*')
d0++;
else if(T->lchild->data!='*'&&T->rchild->data!='*')
{
d2++;
CountBT(T->lchild,d0,d1,d2);
CountBT(T->rchild,d0,d1,d2);
}
else
d1++;
if(T->lchild->data=='*')
CountBT(T->rchild,d0,d1,d2);
else
CountBT(T->lchild,d0,d1,d2);
}
}
void DispBT(BiTree T,int level)
{
int i;
i=level+1;
DispBT(T->rchild,i);
while(level!=0)
{
printf("*");
level--;
}
printf("%c",T->data);
DispBT(T->lchild,i);
}
int main()
{
int d0,d1,d2,m;
char n;
d0=0;
d1=0;
d2=0;
m=0;
BiTree T=NULL;
BiTree t=NULL;
printf("请按照先序遍历的顺序输入字符串(以“#”结尾):");
CreateBT(T);
DispBT(T,m);
ExchangeBT(T);
DispBT(T,m);
printf("请输入您要查找的结点的数据域值:");
scanf("%c",&n);
t=SearchBT(T,n);
if(t->data!=NULL)
{
CountBT(t,d0,d1,d2);
printf("该结点的子树中叶子结点数为%d,度为1的结点数为%d,度为2的结点数为%d",d0,d1,d2);
}
return 0;
