/*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);
}
}
极简,专注,速度,极致