#include <stdio.h>
#include <malloc.h>
#include <stdlib.h>
#define MaxSize 100
typedef char ElemType;
typedef struct BiTNode
{
ElemType data;
struct BiTNode *Lchild;
struct BiTNode *Rchild;
}BiTNode,*BiTree;
Status CreareBiTree(Bitree &T)
{
char ch;
scanf("%c ",&ch);
if(ch==' ')T=NULL;
else
{
if(!(T=(BiTNode *)malloc(sizeof(BiTNode))))
exit (overflow);
T->data=ch;
CreateBiTree(T->Lchild);
CreateBiTree(T->Rchild);
}
return ok;
}
int NM(BiTree T)
{
if(T==NULL) return 0;
else return(NM(T->Lchild)+NM(T->Rchild)+1);
}
Status PreOrder(BiTree T)
{
if(T!=NULL)
{
printf(T->data);
PreOrder(T->Lchild);
PreOrder(T->Rchild);
}
return ok;
}
void main()
{
BiTree T;
printf("输入二叉树:\n");
CreateBiTree(&T);
printf("二叉树结点个数为%d\n",NM(T));
printr("先序遍历输出二叉树:\n");
PreOrder(T);
}