int leafCount(BtreeNode rt)
{
if (rt == NULL) {
return 0;
}
if (rt->left == NULL && rt->right == NULL) {
return 1; // 这个时候是叶子的了
}
return leafCount(rt->left) + leafCount(rt->right);
/* int nCount = 0;
if (rt->left != NULL) {
nCount = leafCount(rt->left);
}
if (rt->right != NULL) {
nCount += leafCount(rt->right);
}
return nCount;
*/
}
[
本帖最后由 yuccn 于 2012-12-26 16:45 编辑 ]