#include
#include
using
namespace
std;
#define
maxsize
100
typedef
struct
binode
{
char
data;
struct
binode
*lchild,*rchild;
}binode,*bitree;
void
create(bitree
&t)//用先序遍历的顺序建立二叉链表(递归方法)
{
char
ch;
cin>>ch;
if(ch=='#')
t=null;
else
{
t=new
binode;
t->data=ch;
create(t->lchild);
create(t->rchild);
}
}
void
preorder(bitree
&t)//先序遍历二叉树(递归)
{
if(t)
{
cout<
data<<"
";
preorder(t->lchild);
preorder(t->rchild);
}
}
void
inorder(bitree
&t)//中序遍历二叉树(递归)
{
if(t)
{
inorder(t->lchild);
cout<
data<<"
";
inorder(t->rchild);
}
}
void
postorder(bitree
&t)//后序遍历二叉树(递归)
{
if(t)
{
postorder(t->lchild);
postorder(t->rchild);
cout<
data<<"
";
}
}
望采纳~~~