用VC调,只是让一直输入,但就是不输出结果,看看!!!!谢谢!!!!!!!
二叉树的建立和遍历 有错误 没结果 帮帮看看#include<iostream>
#include<stdlib.h>
using namespace std;
#define OK 1
#define ERROR 0
#define OVERFLOW -2
typedef int TElemType ;
typedef int Status;
typedef struct BiTNode{
TElemType data;
struct BiTNode *lchild,*rchild;
}BiTNode,*BiTree;
Status CreatBiTree(BiTree &T)154
{
char ch;
cin>>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;
}
Status PreOrder(BiTree &T)
{
if(T)
{
cout<<T->data;
PreOrder(T->lchild);
PreOrder(T->rchild);
}
return OK;
}
int main()
{
BiTree T;
CreatBiTree(T);
PreOrder(T);
return OK;
}