#include<iostream> //引入输入输出流
using namespace std;
#include"BiTee.H" //引入类BiTree的声明
BiNode *BiTree::Creat(Binode *bt)
{
char ch;
cout<<'请输入创建一棵二叉树的结点数据"<<endl;
cin>>ch;
if(ch=='#')return null;
else{
bt=new BiNode; //生成一个结点
bt->data=ch;
bt->lchild=Creat(bt->lchild); //递归建立左子树
bt->rchild=Creat(bt->rchild); //递归建立右子树
}
return bt;
}
void BiTree::release(BiNode *bt)
{
if(bt!=NULL){
release(bt->rchild); //释放左子树
release(bt->rchild); //释放右子树
delete bt;
}
}
void BiTree::PreOrder(BiNode *bt)
{
if(bt==null)return; //递归调用的结速条件
else{
cout<<bt->data<<" "; //访问根结点的数据域
PreOrder(bt->lchild);
PreOrder(bt->rchild);
}
}
voia BiTree::InOrder(BiTree *bt)
{
if(bt==null)return;
else{
InOrder(bt->lchuild);
cout<<bt->data<<" ";
InOrder(bt->rchild);
}
}
void BiTree::PostOrder(BiNode *bt)
{
if(bt==null)return;
else{
PostOrder(bt->lchild);
PostOrder(bt->rchild);
cout<<bt->data<<" ";
}