文档介绍:以下是建的工程;#include<iostream>#include""usingnamespacestd;intmain(){TreeT;cout<<"请先序输入结点数据,其中空结点输入“$”。例:abd$$e$$c$$"<<endl;cout<<"请输入:";Create_tree(T);//建二叉树cout<<"二叉树创建成功!"<<endl<<"先序递归遍历二叉树结果为:";DPre_order(T);cout<<endl;cout<<"非递归先序遍历二叉树结果为:";Pre_order(T);cout<<endl;cout<<"中序遍历二叉树结果为:";In_order(T);cout<<endl;cout<<"后序遍历二叉树结果为:";Post_order(T);cout<<endl;cout<<"二叉树的深度为:"<<Tree_depth(T)<<endl;cout<<"二叉树叶子的个数为:"<<Leafs(T)<<endl;return0;}////#include<iostream>#include""#include""usingnamespacestd;voidCreate_tree(Tree&T)//先序建立二叉树{charch;cin>>ch;if(ch=='$'){T=NULL;}else{if(!(T=newNTree)){exit(1);//空间申请失败}else{T->data=ch;Create_tree(T->lch);Create_tree(T->rch);}}}voidDPre_order(Tree&T){if(T){cout<<T->data<<"";DPre_order(T->lch);DPre_order(T->rch);}}voidIn_order(Tree&T){if(T){In_order(T->lch);cout<<T->data<<"";In_order(T->rch);}}voidPost_order(Tree&T){if(T){Post_order(T->lch);Post_order(T->rch);cout<<T->data<<"";}}intTree_depth(Tree&T){intdepth;if(!T){depth=0;}else{depth=1+(Tree_depth(T->lch)>Tree_depth(T->rch)?Tree_depth(T->lch):Tree_depth(T->rch));//根节点加上左右子树中较深的一个。}returndepth;}intLeafs(Tree&T){if(!T){return0;//空}elseif(!(T->lch)&&!(T->rch)){return1;//叶子}else{return(Leafs(T->lch)+Leafs(T->rch));}}voidPre_order(Tree&T){StackS;creat_S(S);Treep=T;while((p!=NULL)||!Stack_empty(S)){if(p!=NULL){cout<<p->data<<"";push(S,p);p=p->lch;}else{p=gettop(S);del(S);p=p->rch;}}}////#include<iostream>#include<>#include""#defineS_size100#defineAdd10usingnamespacestd;typedefstruct{Treebase;Treetop;intsize;}Stack;voidcreat_S(Stack&S){=(NTree*)malloc(S_size*sizeof(NTree));if(!){cout<<"error"<<endl;exit(0);}=;=S_size;}Treegettop(Stack&S){if(==){cout<<"error"<<endl;exit(0);}--;return(--);}voidpush(Stack&S,Treee){if(->=){=(NTree*)realloc(,(S_size+Add)*sizeof(NTree));