3342 数据结构实验之二叉树三:统计叶子数
来源:互联网 发布:淘宝黑莓手机是真的吗 编辑:程序博客网 时间:2024/06/10 18:06
数据结构实验之二叉树三:统计叶子数
#include<stdio.h> #include<string.h> #include<stdlib.h> char a[100]; int l1; struct node { int data; struct node *lchild,*rchild; }; struct node *creat() { struct node *root; char c; c=a[l1++]; if(c==',') return NULL; else { root=(struct node *)malloc(sizeof(struct node)); root->data=c; root->lchild=creat(); root->rchild=creat(); } return root; } int leave(struct node *root) { if(root==NULL) return 0; if(root->lchild==NULL&&root->rchild==NULL) return 1; else return leave(root->lchild)+leave(root->rchild); } int main() { int i,j,n,m,k,t; struct node *root; while(scanf("%s",a)!=EOF) { l1=0; root=(struct node *)malloc(sizeof(struct node)); root=creat(); k=leave(root); printf("%d\n",k); } return 0; }
0 0
- 3342 数据结构实验之二叉树三:统计叶子数
- 3342数据结构实验之二叉树三:统计叶子数
- 3342 数据结构实验之二叉树三:统计叶子数
- 数据结构实验之二叉树三:统计叶子数
- 数据结构实验之二叉树三:统计叶子数
- 数据结构实验之二叉树三:统计叶子数
- 数据结构实验之二叉树三:统计叶子数
- 数据结构实验之二叉树三:统计叶子数
- 数据结构实验之二叉树三:统计叶子数
- 数据结构实验之二叉树三:统计叶子数
- 数据结构实验之二叉树三:统计叶子数
- 数据结构实验之二叉树三:统计叶子数
- 数据结构实验之二叉树三:统计叶子数
- 数据结构实验之二叉树三:统计叶子数
- 数据结构实验之二叉树三:统计叶子数
- 数据结构实验之二叉树三:统计叶子数
- 数据结构实验之二叉树三:统计叶子数
- 数据结构实验之二叉树三:统计叶子数
- C/C++的64位整型 不同编译器间的比较
- 对URL URI URN的思考
- 并发设计模式之Master-Worker模式
- Android EventBus源码解析 带你深入理解EventBus(转载)
- 关于pt、px、em的转换
- 3342 数据结构实验之二叉树三:统计叶子数
- 51nod-【1393 0和1相等串】
- phpstorm一些常见的快捷键
- Unity的常用快捷键
- Memcached 与 Redis 实现的对比(上)
- 解决Ajax请求跨域问题
- 如何使用sourcetree
- navicat for Mysql查询数据不能直接修改
- HTTP中Get和Post的区别