#include<iostream>
using namespace std;
class tree
{
public:
tree(){lchild=NULL;rchild=NULL;}
char data;
class tree *lchild;
class tree *rchild;
};
void build(tree *&t)//先序建树
{
char c;
cin>>c;
if(c=='#')
{
t=NULL;
}
else
{
t=new tree;
t->data=c;
build(t->lchild);
build(t->rchild);
}
}
void preorder(tree *root)//这是递归实现
{
if (root!=NULL)
本内容试读结束,登录后可阅读更多
下载后可阅读完整内容,剩余3页未读,立即下载