#include<iostream>
using namespace std;
typedef struct BiNode{
char data;
struct BiNode *lchild,*rchild;
}BiTNode,*BiTree;
//先序建立二叉链表
void CreateBiTree(BiTree &T){
char ch;
cin >> ch;
if(ch=='#') T=NULL;
else{
T=new BiTNode;
T->data=ch;
CreateBiTree(T->lchild);
CreateBiTree(T->rchild);
}
}
//先序遍历
void Pre(BiTree T){
if(T){
cout<<T->data;
Pre(T->lchild);
Pre(T->rchild);
}
}
//中序遍历
void In(BiTree T){
if(T){
In(T->lchild);
cout<<T->data;
In(T->rchild);
}
}
//后序遍历
void Post(BiTree T){
if(T){
Post(T->lchild);
Post(T->rchild);
cout<<T->data;
}
}
int main(){
BiTree tree;
cout<<"先序建立二叉链表:";
CreateBiTree(tree);
cout<<"先序遍历的结果为:";
Pre(tree);
cout<<endl;
cout<<"中序遍历的结果为:";
In(tree);
cout<<endl;
cout<<"后序遍历的结果为:";
Post(tree);
cout<<endl;
}

**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。