您好,你发的这个题目,其实就是考察你用递归的方式来获取整个二叉树的高度的。前面的lh,rh,hi分别是变量,后面的mtheight是获取高度的函数名
具体代码如下:
mtheight( struct nitnoexp )
{
if( p ){
//左子树高度
if(p->lchild == null)
lh = 0;
else
lh = mtheight(p->lchild);
//右子树高度
if(p->rchild == null)
rh = 0;
else
rh = mtheight(p->rchild);
//判断
if(lh>rh)
hi = lh + 1;
else
hi = rh + 1;
}else if(p == null){
return hi;
}
}