#define _CRT_SECURE_NO_WARNINGS
#include<stdint.h>
#include"iostream"
#define OK 1
#define ERROR 0
#define MAXLEN 100
#define DataType char
typedef struct Node{
DataType data;
struct Node * Lchild;
struct Node * Rchild;
}BiTNode, *BiTree;
void Visit(DataType data)
{
printf("%c", data);
}
void qianxv(BiTree root)
{
if (root)
{
Visit(root->data);
qianxv(root->Lchild);
qianxv(root->Rchild);
}
}
void zhongxv(BiTree root){
if (root){
zhongxv(root->Lchild);
Visit(root->data);
zhongxv(root->Rchild);
}
}
void houxv(BiTree root)
{
if (root)
{
qianxv(root->Lchild);
qianxv(root->Rchild);
Visit(root->data);
}
}
void CreateBiTree(BiTree *T)
{
DataType ch;
scanf("%c", &ch);
if (ch == '#')
{
*T = NULL;
}
else
{
*T = (BiTree)malloc(sizeof(BiTNode));
(*T)->data = ch;
CreateBiTree(&(*T)->Lchild);
CreateBiTree(&(*T)->Rchild);
}
}
int NodeCount(BiTree T)
{
if (T == NULL) return 0;
else return NodeCount(T->Lchild) + NodeCount(T->Rchild) + 1;
}
int leafCount(BiTree T)
{
if (T == NULL) return 0;
if (T->Lchild == NULL&&T->Rchild == NULL) return 1;
else return leafCount(T->Lchild) + leafCount(T->Rchild);
}
int gethight(BiTree T)
{
if (T == NULL) return 0;
int L = gethight(T->Lchild);
int R = gethight(T->Rchild);
return ((L > R) ? (L + 1) : (R + 1));
}