1 int GetHeight(BinTree BT) 2 { 3 int HL, HR, MaxH; 4 5 if(BT) 6 { 7 HL = GetHeight(BT->Left); //求左子树的高度 8 HR = GetHeight(BT->Right); //求右子树的高度 9 MaxH = (HL > HR) ? HL : HR; //取左右子树较大的高度10 return MaxH + 1; //返回树的高度11 }12 else 13 return 0; //空树高度为014 }