include
include
include
include
using namespace std;
struct Tree
{
char info;
Tree *Left;
Tree *Right;
};
int pos=0;
int sum=0;
Tree *Root;
string strTree;
void initString(string s)
{
strTree.assign(s);
pos=0;
}
Tree* CreateBiTree()//通过先序遍历的结果来构建二叉树
{
Tree *T;
char ch;
ch=strTree[pos++];
if(ch==’0’)
T=NULL;
else
{
T=new Tree;
T->info=ch;
T->Left=CreateBiTree();
T->Right=CreateBiTree();
}
return T;
}
void LevelOrder(Tree *s)//层次遍历二叉树
{
queue