二叉树求高度的部分,老师给的答案,没看懂,求解答
int hauteur (t_noeud * racine)
{
int h=0,hfils=0,i;
if( racine->nbfils==0) return 0;
for (i = 0; i < racine->nbfils; i++)
{
hfils=hauteur(racine->fils[i]);
if (hfils>h) h=hfils;
}
return h+1;
}
麻烦讲解一下程序怎么走的,怎么return的,谢谢啦
忘了说明noeud了~~
typedef struct noeud {
double value;
int height;
struct noeud struct noeud struct noeud *pere;
int nbfils ;
struct noeud ** fils;
int rang;
} t_noeud;
[解决办法]
if( racine->nbfils==0) return 0;
这儿return的