UVA 699 The Falling Leaves
来源:互联网 发布:iphone6s软件打不开 编辑:程序博客网 时间:2024/05/10 03:27
#include <cstdio>int arr[82] = {0}, count = 0;int deal(int move) {int left, right;scanf("%d", &left);if (left != -1) { //判断有没左子结点arr[move - 1] += left; //有的话数组左移一位,并存入左子结点deal(move - 1); // 判断左子结点是否有子结点}scanf("%d", &right);if (right != -1) {arr[move + 1] += right;deal(move + 1);}return 0;}int main() {while (scanf("%d", &arr[40]), arr[40] + 1) { //数组的arr[40] 存根结点printf("Case %d:\n", ++count);deal(40); //判断根结点有无子结点for (int i = 0; i < 81; i++)if (arr[i] != 0) //输出不为零的数组元素,并初始化该数元素arr[i + 1] == 0 ? printf("%d", arr[i]) : printf("%d ", arr[i]), arr[i] = 0;printf("\n\n");}return 0;}
0 0
- uva 699 - The Falling Leaves
- uva 699 The Falling Leaves
- uva 699 - The Falling Leaves
- UVa 699 - The Falling Leaves
- UVA 699 - The Falling Leaves
- UVa 699 - The Falling Leaves
- uva 699 The Falling Leaves
- uva-699 The Falling Leaves
- UVA 699 The Falling Leaves
- uva 699 The Falling Leaves
- UVA 699 - The Falling Leaves
- uva 699 The Falling Leaves
- uva 699 - The Falling Leaves
- UVa 699 - The Falling Leaves
- UVA 699 The Falling Leaves
- UVA - 699 The Falling Leaves
- UVA 699 The Falling Leaves
- UVA - 699 The Falling Leaves
- storm环境下重写bolt实现读写hdfs
- Matches Game(尼姆博弈)
- 【 JavaScript 】几个常用的 JavaScript 框架比较
- h:panelGrid、h:panelGroup标签学习
- 免费的HTML5连载来了《HTML5网页开发实例详解》连载(六)媒体查询
- UVA 699 The Falling Leaves
- 管理看板-分列式面板拖拽组件
- shell使用随笔
- 关于having,group by 的Sql 语句
- SpringMVC中避免拦截css,js,html图片等静态文件
- uva 10130 SuperSale
- 一道hdu 2063彻底搞懂二分匹配--匈牙利算法
- Activity在onStop后到底处于什么状态?
- HDU 2563 统计问题【递推】