#include <stdio.h>
#include <stdlib.h>
#define MAX 20
#define NULL 0
typedef char TElemType;
typedef int Status;
typedef struct BiTNode{
TElemType data;
struct BiTNode *lchild,*rchild;
}BiTNode,*BiTree;
Status CreateBiTree(BiTree *T)
{//输入二叉树的先序遍历序列,创建二叉链表
char ch;
ch=getchar();
if (ch=='&') (*T)=NULL;
else {
(*T)=(BiTree) malloc(sizeof(BiTNode));
(*T)->data=ch;
CreateBiTree(&(*T)->lchild) ;
CreateBiTree(&(*T)->rchild) ;
}//end of if
return 1;
}//end of creatbintree
void PreOrder(BiTree T)
{//对二叉树进行先序遍历
if (T) {
printf("%c",T->data);
PreOrder(T->lchild);
PreOrder(T->rchild);
}//end of if
}//end of preorder
void Cenview(BiTree T)
{////对二叉树进行中序遍历
if (T) {
Cenview(T->lchild);
printf("%c",T->data);
Cenview(T->rchild);
}//end of if
}//end of inorder
void Lview(BiTree T)
{//对二叉树进行后序遍历
if (T) {
Lview(T->lchild);
Lview(T->rchild);
printf("%c",T->data);
}//end of if
}//end of postorder
main(){
BiTree T=NULL;
printf("please input nodes of bintree:\n");
CreateBiTree(&T);
printf("\nThe preorder is:\n");
PreOrder(T);
printf("\nThe inorder is:\n");
Cenview(T);
printf("\nThe postorder is:\n");
Lview(T);
printf("\n");
return 0;
}