二叉树的建立与遍历有问题啊~~~~~~~
#define OK 1#define NULL 0
typedef struct BitNode
{
char data;
struct BitNode *lchild,*rchild;
}BitNode,*BitTree //*定义二叉树的二叉链表结点*//;
main()
{
int CreateBitTree(BitTree *T);
int PreOrder (BitTree T);
BitTree tree;
CreateBitTree(&tree);
printf("\n");
PreOrder (tree);
getch();
InOrder(tree);
PostOrder(tree);
return OK;
} //*主函数段*//
int CreateBitTree(BitTree *T)
{
char ch;
scanf("%c",&ch);
if(ch==' ') *T=0;
else
{
*T=(BitNode*)malloc(sizeof(BitNode));
(*T)->data=ch;
CreateBitTree(&((*T)->lchild));
CreateBitTree(&((*T)->rchild));
}
return OK;
} //*以先序遍历创建二叉树*//
int PreOrder (BitTree T)
{
if(T)
{
printf("%c",T->data);
PreOrder (T->lchild);
PreOrder (T->rchild);
}
else
return OK;
} //*先序遍历二叉树*//
int InOrder(BitTree T)
{
InOrder (T->lchild);
printf(“%c”,T->data);
InOrder (T->rchild);
}
else
return OK; //*中序遍历二叉树*//
}
Int PostOrder (BitTree T)
{
PostOrder (T->lchild);
PostOrder (T->rchild);
Printf(“%c”,T->data);
}
else
return OK;
} //*后序遍历二叉树*//