/*tips:最后返回指针很重要 bt root=NULL;root=Create(root);*/
#include<iostream>
using namespace std;
typedef struct Btree
{
	char data;
	Btree *lchild,*rchild;
}Btree,*bt;
bt Create(bt T);
void DisplayTree(bt T);
void main()
{
	bt root=NULL;
	root=Create(root);
	DisplayTree(root);
}
bt Create(bt T)
{
	
	char ch;
	cin>>ch;
	if(ch=='#')
		T=NULL;
	else
	{
		T=new Btree;
		T->data=ch;
		T->lchild=Create(T->lchild);
		T->rchild=Create(T->rchild);
	}
	return T;
}
void DisplayTree(bt T)
{
	if(T!=NULL)
	{
		cout<<T->data<<'\t';
		DisplayTree(T->lchild);
		DisplayTree(T->rchild);
	}
	
}

 posted on 2014-03-23 10:28  mnmlist1  阅读(180)  评论(0编辑  收藏  举报