#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<stdlib.h>
using namespace std;
#define status int
typedef struct bitnode
{
char data;
struct bitnode *lchild;
struct bitnode *rchild;
} bitnode,*sq;
int r=0;
bitnode *q;
int num=0;
int high=0;
void createbitree(sq &T)
{
char ch;
scanf("%c",&ch);
if(ch=='#')
T=NULL;
else
{
T=(bitnode *)malloc(sizeof(bitnode));
T->data=ch;
if(r==0)
{
q=T;
r=1;
}
createbitree(T->lchild);
createbitree(T->rchild);
}
}
void leafcount(sq &T)
{
if(T!=NULL)
{
if(T->lchild==NULL&&T->rchild==NULL)
num++;
leafcount(T->lchild);
leafcount(T->rchild);
}
}
status hightree(sq &T)
{
int h1,h2,h;
if(T==NULL)
h=0;
if(T!=NULL)
{
h1=hightree(T->lchild);
h2=hightree(T->rchild);
h=(h1>h2?h1:h2)+1;
}
return h;
}
int main()
{
bitnode *t;
printf("createbitree:");
createbitree(t);
t=q;
printf("leafcount:");
leafcount(t);
printf("%d\n",num);
printf("hightree:");
printf("%d\n",hightree(t));
}