#include<stdio.h>
#include<stdlib.h>
#define SIZE 23
typedef struct BiTNode
{char data;
struct BiTNode *Lchild,*Rchild;
}BiTNode,*BiTree;
BiTree creatBiTree(BiTree T)
{char ch;
BiTree T0;
scanf("%c",&ch);
if(ch=='#') T0=NULL;
else{
T=(BiTNode *)malloc(sizeof(BiTNode));
T->data=ch;
creatBiTree(T->Lchild);
creatBiTree(T->Rchild);
T0=T;
}
return(T0);
}
void Ctraverse(BiTree T)
{BiTree V[SIZE],p;
int front=0,area=0;
if(T!=NULL)
{area++;
V[area]=T;
while(front<area)
{front++;
p=V[front];
printf("%d,",p->data);
if(p->Lchild!=NULL) {area++;V[area]=p->Lchild;}
if(p->Rchild!=NULL) {area++;V[area]=p->Rchild;}
}
}
}
void main()
{BiTree T;
T=creatBiTree(T);
Ctraverse(T);
getch();
}似乎是输入不能结束