习题3-求二叉树深度.c
来自「数据结构各章实验源代码; 数据结构实验源代码」· C语言 代码 · 共 27 行
C
27 行
#include <stdio.h>
#include "datastru.h"
#include <malloc.h>
#include "二叉树.c"
int treehight(BTCHINALR *bt)
{ int lh, rh, h;
if(bt == NULL)
h = 0;
else
{ lh = treehight(bt->lchild);
rh = treehight(bt->rchild);
h = (lh > rh ? lh : rh) + 1; }
return h;
}
main( )
{ BTCHINALR *bt;
int treeh;
bt = createbt( );
treeh = treehight(bt);
printf("\n二叉树深度 = %d\n\n",treeh);
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?