向高人请教,这程序结果为啥出不来??
本帖最后由 qzc1144742081 于 2011-5-22 19:26 编辑#include <iostream>
using namespace std;
#define OK 1
#define OVERFLOW 0
typedef char Status;
typedef char TElemType;
typedef struct BiTNode
{
TElemType data;
struct BiTNode *lchild,*rchild;
}BiTNode,*BiTree;
Status CreateBiTree(BiTree &T)
{
char ch;
ch=getchar();
if((ch=getchar())==' ') T=NULL;
else
{
if(!(T=new BiTNode)) exit(OVERFLOW);
T->data=ch;
CreateBiTree(T->lchild);
CreateBiTree(T->rchild);
}
return OK;
}
void PerOrder(BiTree T)
{
if(T!=NULL)
{
cout<<T->data<<" ";
PerOrder(T->lchild);
PerOrder(T->rchild);
}
}
void InOrder(BiTree T)
{
if(T!=NULL)
{ InOrder(T->lchild);
cout<<T->data<<" ";
InOrder(T->rchild);
}
}
void PosterOrder(BiTree T)
{
if(T!=NULL)
{
PosterOrder(T->lchild);
PosterOrder(T->rchild);
cout<<T->data<<" ";
}
}
void main()
{
BiTree T;
CreateBiTree(T);
PerOrder(T);
InOrder(T);
PosterOrder(T);
}
页:
[1]