文章
34
粉丝
316
获赞
10
访问
22.2k
#include<bits/stdc++.h>
using namespace std;
typedef struct TNode {
int val;
struct TNode* rchild, * lchild;
}*Tree;
void BuildTree(Tree& t, int val)
{
if (val <0) return;
t = new TNode;
t->val = val;
t->lchild = NULL;
t->rchild = NULL;
BuildTree(t->lchild, val - 1);
BuildTree(t->rchild, val - 2);
}
//获取叶子结点个数
void GetLeaveNum(Tree t,int &result)
{
if (t == NULL) return;
if (t->lchild == NULL && t->rchild == NULL) result++;
GetLeaveNum(t->lchild, result);
GetLeaveNum(t->rchild, result);
}
int main()
{
int n;
while (cin >> n)
{
 ...
登录后发布评论
暂无评论,来抢沙发