4 8 求二叉樹高度 20分

2022-03-06 04:14:35 字數 1194 閱讀 8944

4-8 求二叉樹高度 (20分)

本題要求給定二叉樹的高度。

int getheight( bintree bt );
其中bintree結構定義如下:

typedef struct tnode *position;

typedef position bintree;

struct tnode;

要求函式返回給定二叉樹bt的高度值。

#include #include typedef char elementtype;

typedef struct tnode *position;

typedef position bintree;

struct tnode;

bintree creatbintree(); /* 實現細節忽略 */

int getheight( bintree bt );

int main()

/* 你的**將被嵌在這裡 */

4
程式**:

1//2

4-8 求二叉樹高度

4 #include5 #include6 #include7 #include

8using

namespace

std;

9#define overflow -2

10 typedef char

elementtype;

11 typedef struct tnode *position;

12typedef position bintree;

13struct

tnode;

1819

bintree creatbintree()

25int

getheight( bintree bt );

2627

intmain()

28

1

/*你的**將被嵌在這裡 */2

int getheight(bintree bt)//

輸出二叉樹的高度314

return

high;

15 }

6 1 求二叉樹高度(20 分)

int getheight bintree bt 其中bintree結構定義如下 typedef struct tnode position typedef position bintree struct tnode 要求函式返回給定二叉樹bt的高度值。include include typedef...

6 1 求二叉樹高度 (20 分)

本題要求給定二叉樹的高度。函式介面定義 int getheight bintree bt 其中bintree結構定義如下 typedef struct tnode position typedef position bintree struct tnode 要求函式返回給定二叉樹bt的高度值。裁判測...

6 8 求二叉樹高度 20分

本題要求給定二叉樹的高度。函式介面定義 int getheight bintree bt 其中bintree結構定義如下 typedef struct tnode position typedef position bintree struct tnode 要求函式返回給定二叉樹bt的高度值。裁判測...