// 定义二叉树结点结构
struct TreeNode {
int data;
struct TreeNode *left;
struct TreeNode *right;
};
// 计算二叉树叶子结点数的递归函数
int count(struct TreeNode *r) {
if (r == NULL) {
return 0;
} else if (r->left == NULL && r->right == NULL) {
return 1; // 叶子结点
} else {
return count(r->left) + count(r->right);
}
}