#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
typedef char ElementType;
typedef struct TNode *Position;
typedef Position BinTree;
struct TNode{
ElementType Data;
BinTree Left;
BinTree Right;
};
BinTree CreatBinTree();
int GetHeight( BinTree BT );
int main()
{
BinTree BT = CreatBinTree();
printf("%d\n", GetHeight(BT));
return 0;
}
int GetHeight( BinTree BT ){
int high=0;
if(BT==NULL){
return 0;
}
high++;
int lh=GetHeight(BT->Left);
int rh=GetHeight(BT->Right);
int max=0;
if(lh>rh){
max=lh;
}else{
max=rh;
}
return high+max;
}
|