UVa 699 - The Falling Leaves【递归】
来源:互联网 发布:java并发编程的例子 编辑:程序博客网 时间:2024/05/20 16:41
原题网址:
https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=640
继续加油!就算写不出来这样精简的程序,也算涨涨知识了!
///什么时候才能掌握递归啊#include<stdio.h> #include<string.h>const int maxn=100005;int sum[maxn];void build(int p){int v;scanf("%d",&v);if(v==-1){return;}sum[p]+=v;build(p-1);build(p+1);}bool init(){int v;scanf("%d",&v);if(v==-1){return 0;}memset(sum,0,sizeof(sum));int pos=maxn/2;//从中间开始统计,以防溢出sum[pos]=v;build(pos-1);build(pos+1);} int main(){int kase=0;//freopen("shuju.txt","r",stdin);while(init()){int p=0;//输出的时候从最左边开始找...while(sum[p]==0){p++;}printf("Case %d:\n%d",++kase,sum[p++]);while(sum[p]!=0){printf(" %d",sum[p++]);}printf("\n\n");}return 0;}
0 0
- UVa 699 The Falling Leaves(递归建树)
- UVa 699 - The Falling Leaves【递归】
- 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
- .android view绘制过程
- 如何调试 SDWebImage,使用前的准备工作
- python:解析js中常见的 不带引号的key的 json
- 控件设计
- DIV 里 table 居中的问题
- UVa 699 - The Falling Leaves【递归】
- many to one
- leetcode总结-- heapq运用,关于super ugly number, merge k sorted list
- 解决CSS透明度被继承问题
- 让多个Fragment 切换时不重新实例化
- 误删也能找!清空回收站后文件找回技巧
- Collection集合
- android开发环境搭建(for 驱动开发人员) .
- Struts2常用标签总结