数据结构二叉树的问题

编写程序如下,似乎实现不了要求的功能,望高手指点··
#include <stdlib.h>
#include <iostream>
using namespace std;
typedef struct BTnode{
char data;
struct BTnode *lchild,*rchild;
}note;
note *creat()
{
note *t;
char ch;
cin>>ch;
if(ch=='0')
t=NULL;
else
{
t=new note;
t->data=ch;
t->lchild=creat();
t->rchild=creat();
}
return t;
}
void xianxu(note *t)
{
if(t!=NULL)
{
cout<<t->data;
xianxu(t->lchild);
xianxu(t->rchild);
}
}
void zhongxu(note *t)
{
if (t!=NULL)
{
zhongxu(t->lchild);
cout<<t->data;
zhongxu(t->rchild);
}
}
void houxu(note *t)
{
if(t!=NULL)
{
houxu(t->lchild);
houxu(t->rchild);
cout<<t->data;
}
}
int main()
{
note *t;
t=creat();
cout<<"先序遍历为:"<<endl;
xianxu(t);
cout<<endl;
cout<<"中序遍历为:"<<endl;
zhongxu(t);
cout<<endl;
cout<<"后序遍历为:"<<endl;
houxu(t);
cout<<endl;
return 0;
}
我检毕穗验了一下帆数链,你的程序是对的
运行结果态孙
abc00de0f00g000
先序遍历为:
abcdefg
中序遍历为:
cbefdga
后序遍历为:
cfegdba

Press any key to continue