The Falling Leaves UVA
来源:互联网 发布:全球社交软件排名 编辑:程序博客网 时间:2024/06/06 08:15
问题类型:二叉树,DFS
03pie’s solution for [UVA-699]:
题目链接
#include<iostream> #include<cstring>using namespace std;const int maxn=1000;int sum[maxn];void build(int p){ int v;cin>>v; if(v==-1) return; sum[p]+=v; build(p-1); build(p+1);}bool init(){ int v; cin>>v; if(v==-1) return false; memset(sum,0,sizeof(sum)); int pos=maxn/2; sum[pos]=v; build(pos-1); build(pos+1);}int main(){ int kase=0; while(init()){ int p=0; while(sum[p]==0) p++; cout<<"Case "<<++kase<<":\n"<<sum[p++]; while(sum[p]!=0) cout<<" "<<sum[p++]; cout<<"\n\n"; } return 0;}
0 0
- uva-The falling leaves
- The Falling Leaves UVA
- The Falling Leaves UVA
- The Falling Leaves UVA
- 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
- easyUI datagrid数据导出为Excel
- 2014年以来高被引论文
- java ------华为上机机试--计算字符串个数
- Problem D: 线性表的基本操作
- ZCMU—1907
- The Falling Leaves UVA
- github atom 安装activate-power-mode插件详细教程
- org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'g': Injectio
- LR菜鸟入门 -- LightRoom安装/预设
- nswoj-打水
- GitHub操作
- 地址收藏
- 从零开始搭建阿里云服务器
- Problem B: 求个最大值