#include <stdio.h>
#include <stdlib.h>
typedef struct tree{
int data;
struct tree *lchild,*rchild;
}node,*bitree;
void creat(bitree *t){
int value;
scanf("%d",&value);
if(value==-1)
*t=NULL;
else{
*t=(bitree)malloc(sizeof(node));
(*t)->data = value;
creat(&(*t)->lchild);
creat(&(*t)->rchild);
}
}
void hpost(bitree t){
if(t==NULL);
else{
hpost(t->lchild);
printf("%d",t->data);
hpost(t->rchild);
}
}
int gethigh(bitree t){
if(t==NULL){
return 0;
}else{
int len = gethigh(t->lchild);
int ren = gethigh(t->rchild);
if(len>ren){
return len+1;
}else{
return ren+1;
}
}
}
int main(){
bitree t;
//构建一个二叉树
creat(&t);
//中序遍历
hpost(t);
//二叉树深度
int a=gethigh(t);
printf("二叉树的高度为%d",a);
return 0;
}