UVA 699 The Falling Leaves
2011-12-28 23:41
375 查看
UVA_699
模拟题目所说的即可。
模拟题目所说的即可。
#include<stdio.h> #include<string.h> #define MAXD 160 #define MID 80 int first, f[MAXD]; void dfs(int cur) { int k; scanf("%d", &k); if(k == -1) return ; if(f[cur] == -1) f[cur] = k; else f[cur] += k; dfs(cur - 1); dfs(cur + 1); } void solve() { int i; memset(f, -1, sizeof(f)); f[MID] = first; dfs(MID - 1); dfs(MID + 1); for(i = 0; f[i] == -1; i ++); printf("%d", f[i ++]); for(; f[i] != -1; i ++) printf(" %d", f[i]); printf("\n"); } int main() { int t = 0; for(;;) { scanf("%d", &first); if(first == -1) break; printf("Case %d:\n", ++ t); solve(); printf("\n"); } return 0; }
相关文章推荐
- uva 699 The Falling Leaves
- uva 699 The Falling Leaves
- ACM篇:Uva 699 -- The Falling Leaves
- uva-699 The Falling Leaves
- UVA 699 The Falling Leaves
- UVA 699 - The Falling Leaves
- UVA699-例题6-10 下落的树叶(The Falling Leaves,UVa 699)
- UVa 699 - The Falling Leaves【递归】
- The Falling Leaves UVA - 699
- UVA - 699 The Falling Leaves
- UVA 699 - The Falling Leaves(从中间向两边递归perfect)
- UVA.699 The Falling Leaves (二叉树 思维题)
- Uva 699 - The Falling Leaves
- UVa 699 - The Falling Leaves
- uva699 the falling leaves
- UVa 699 The Falling Leaves (DFS遍历二叉树)
- UVA 699 The Falling Leaves(二叉树|DFS)
- UVa 699 - The Falling Leaves
- UVa 699.The Falling Leaves【7月23】
- The Falling Leaves 下落的树叶 UVA 699(二叉树)