#include<stdio.h>
#include<malloc.h>
struct node{//建树 过程中输入这个树
char info;
struct node *llink,*rlink;
};
typedef struct node NODE;
NODE *creat(){
char x;
NODE *p;
scanf("%c",&x);
// printf("%c",x);//检验结果
if(x!='.')
{
p=(NODE *)malloc(sizeof(NODE));
p->info=x;
p->llink=creat();
p->rlink=creat();
}
else
p=NULL;
return p;
}/*
typedef struct TNode//二叉树结构
{
char nodeValue;//结点的值
TNode* left;//左子树
TNode* right;//右子树
}*BiTree;
void CreateBiTree(BiTree &T)//中序遍历方式创建二叉树 ,输入.代表该结点为空
{
char nodeValue;
cin>> nodeValue;
if(nodeValue!='.')//结点非空
{
T=new TNode;
T->nodeValue=nodeValue;
CreateBiTree(T->left);
CreateBiTree(T->right);
}
else T=NULL;
}
*/
void run(NODE *t){//中序遍历
if(t){
run(t->llink);printf("%c",t->info);
run(t->rlink);
}
}
/*
void run(NODE *t){//先序遍历
if(t){
printf("%c",t->info);
run(t->llink);
run(t->rlink);
}
void run(NODE *t){//后序遍历
if(t){
run(t->llink);
run(t->rlink);
printf("%c",t->info);
}
}
}
*/
main()
{
NODE *T;
printf("PLease input a tree:\n");
T=creat();
printf("\n");
if(!T)
printf("This is a empty binary tree.");
else
{ printf("The result of post travese is:\n ");
run(T);
}
printf("\n");
}