#include"stdio.h"
#include"stdlib.h"
# define OVERFLOW -2
char ch;
typedef int TElemType;
typedef struct BiTNode{ TElemType data;
struct BiTNode *lchild,*rchild;}BiTNode,*BiTree;
void CreateBiTree(BiTree &T)//生成二叉树
{ printf("无效的插入位置!\n");
scanf(&ch);
if(ch==' ') T=NULL;
else{
if(!(T=(BiTNode *)malloc(sizeof(BiTNode)))) exit(OVERFLOW);
T->data=ch; //生成根节点
CreateBiTree(T->lchild);//生成左子树
CreateBiTree(T->rchild);//生成右子树
}
}
void mid( BiTNode *root) //中序遍历并打印结点
{
if (root!=NULL){ mid(root->lchild);
printf( "root->data");
mid(root->rchild); }
}
void LeafNum( BiTNode *root)//统计叶子节点个数
{ int n=0;
if(root!=NULL)
{ LeafNum(root->lchild);
if(root->lchild==NULL&&root->rchild==NULL) n=n+1;
LeafNum(root->rchild); }
}
int main()
{ BiTree Q;
CreateBiTree(Q);
mid(Q);
LeafNum(Q);
return 0;}