#include
#include
typedef struct TNode
{
char data;
struct TNode* lchild;
struct TNode* rchild;
}TNode;
TNode* creat()
{
char x;
TNode* pT;
scanf("%c", &x);
if (x == '#')
pT = NULL;
else
{
pT = (TNode*)malloc(sizeof(TNode));
pT->data = x;
pT->lchild = creat();
pT->rchild = creat();
}
return pT;
}
void op(TNode* pT)
{
if (pT != NULL)
{
op(pT->lchild);
op(pT->rchild);
printf("%c", pT->data);
}
}
int main()
{
TNode* pT;
pT = creat();
op(pT);
return 0;
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)