|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本帖最后由 tyl555 于 2022-5-21 19:41 编辑
#include <stdio.h>
#include <stdlib.h>
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 )
{
if(BT==NULL)return 0;
int max;
max=GetHeight(BT->Left);
if(max<GetHeight(BT->Right))
max=GetHeight(BT->Right);
return max+1;
} |
|