二叉树的遍历怎么实现不了
#include<stdio.h>#include<stdlib.h>
#define TRUE 1
#define FALSE 0
#define OK 1
#define ERROR 0
#define INFEASIBLE -1
#define OVERFLOW -2
#define MAX_TREE_SIZE 100
typedef char TElemType;
typedef int Status;
typedef struct BiTNode{
char data;
struct BiTNode *lchild,*rchild;
}BiTNode,*BiTree;
int CreatBiTree(BiTree &T){
char ch;
scanf(&ch);
if(ch==' ') T=NULL;
else{
if(!(T = (BiTNode *)malloc(sizeof(BiTNode))))exit(OVERFLOW);
T->data=ch;
CreatBiTree(T->lchild);
CreatBiTree(T->rchild);
}
return OK;
}
void TraverseBiTree(BiTree T){
char ch;
if(NULL==T)
return ;
printf("%c",T->data);
TraverseBiTree(T->lchild);
TraverseBiTree(T->rchild);
}//先序
void InOrder(BiTree T){
char ch;
if(NULL==T)
return ;
InOrder(T->lchild);
printf("%c",T->data);
InOrder(T->rchild);
}//中序
void PostOrder(BiTree T){
char ch;
if(NULL==T)
return ;
PostOrder(T->lchild);
PostOrder(T->rchild);
printf("%c",T->data);
}//后序
int main()
{ char ch;
struct BiTNode *T=0;
CreatBiTree(T);
printf("中序遍历:\n");
InOrder(T);
printf("\n");
printf("先序遍历:\n");
TraverseBiTree(T);
printf("\n");
printf("后序遍历:\n");
PostOrder(T);
return OK;
}