#include <stdio.h>
#include <vector>
#include <list>
#include<iostream>
using namespace std; struct BinaryTree{
int weight;
struct BinaryTree *left,*right;
};
int subtree_count(const struct BinaryTree *root,int m){
int temp_val;
static int count = ;
static int result=;
int left=;
int right=;
int flag=;
if(count == ){
flag =;
}
count ++;
if(root==NULL){
return ;
} if(root->left!=NULL){
left = subtree_count(root->left,m);
}
if(root->right!=NULL){
right = subtree_count(root->right,m);
}
temp_val = left + right+root->weight;
if(temp_val == m)
result++;
if(flag)
return result;
else
return temp_val;
} int main()
{
int input=;
//cin >> input;
BinaryTree *root1 = new BinaryTree;
root1->weight=; BinaryTree *root2 = new BinaryTree;
root2->weight=;
BinaryTree *root3 = new BinaryTree;
root3->weight=;
BinaryTree *root4 = new BinaryTree;
root4->weight=;
BinaryTree *root5 = new BinaryTree;
root5->weight=;root4->right=NULL; root1->left=root2;
root1->right=root3;
root2->left=root4;
root2->right=root5;
root4->right=NULL;
root4->left=NULL;
root5->right=NULL;
root5->left=NULL;
root3->right=NULL;
root3->left=NULL;
cout <<subtree_count(root1,input);
return ;
}

最新文章

  1. jdk源码分析红黑树——插入篇
  2. Spring IoC容器初始化过程学习
  3. WebApi服务Uri加密及验证的两种方式
  4. mysql 连接超时解决
  5. serialize-and-deserialize-bst
  6. QFrame好像是万能的(可以随意画线,或者图片,放在其它元素之间做点缀,还可OnClick)
  7. Linux多线程编程的时候怎么查看一个进程中的某个线程是否存活
  8. phalcon——闪存消息
  9. Sqoop葵花宝典
  10. 自主学习python文本进度条及π的计算
  11. redis 3.2 新数据结构:quicklist、String的embstr与raw编码方式分界点
  12. JavaEE 要懂的小事:三、图解Session(会话)
  13. 跨平台、跨语言应用开发,Elements 介绍
  14. Sethi model
  15. JS实现选择菜单栏(配合慕课网淘宝搜索框的课程)
  16. SDN 第三次作业
  17. cojs 强连通图计数1-2 题解报告
  18. 2018.08.11 洛谷P3224 [HNOI2012]永无乡(线段树合并)
  19. CRFPP/CRF++编译安装与部署
  20. PyQt4菜单栏

热门文章

  1. 贝叶斯方法(Bayesian approach) —— 一种概率解释(probabilistic interpretation)
  2. Java内部类——学习笔记
  3. OpenGL(七) 光照模型及设置
  4. 微信小程序知识集锦
  5. JSON的一些要点总结 专题
  6. SSM导出报表为csv文件
  7. SharePoint 2010 WebPart Web部分 总的膏
  8. jquery li练习2-恢复链条
  9. entity framework 封装基类
  10. ASP.NET MVC 学习笔记1 Talk about controller &amp; route