http://acm.hdu.edu.cn/showproblem.php?pid=2162

Problem Description
Write a program to determine the summation of several sets of integers.
 
Input
The input file will consist of up to 250 sets of integers, where each set contains at most 100 integers and the integer values will be between –16000 and + 16000. Each set of numbers is started with the number of integers in the set, n. The next n input lines will each contain one integer of the set. You should stop processing when the size of the set, n, is<= 0.
 
Output
A single line of output should be generated for each set of integers. The line should have format shown below.
 
Sample Input
4
-1
3
1
1
2
19
17
5
-645
952
-1488
-5456
-9342
-1
 
Sample Output
Sum of #1 is 4
Sum of #2 is 36
Sum of #3 is -15979
 
代码:

#include <bits/stdc++.h>
using namespace std; int a[1111]; int main() {
int n, cnt = 0;
while(~scanf("%d", &n)) {
getchar();
if(n <= 0) break;
cnt ++;
int sum = 0;
for(int i = 1; i <= n; i ++) {
scanf("%d", &a[i]);
sum += a[i];
} printf("Sum of #%d is %d\n", cnt, sum); }
return 0;
}

  

HDU 2162 Add ‘em的更多相关文章

  1. HDOJ(HDU) 2162 Add ‘em(求和)

    Problem Description Write a program to determine the summation of several sets of integers. Input Th ...

  2. HDU 2162(注意初始化位置!)

    Add ‘em Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Sub ...

  3. HDU 6033 - Add More Zero | 2017 Multi-University Training Contest 1

    /* HDU 6033 - Add More Zero [ 简单公式 ] | 2017 Multi-University Training Contest 1 题意: 问 2^n-1 有几位 分析: ...

  4. 2017 Multi-University Training Contest - Team 1 1001&&HDU 6033 Add More Zero【签到题,数学,水】

    Add More Zero Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)T ...

  5. HDU 6033 Add More Zero (数学)

    Description There is a youngster known for amateur propositions concerning several mathematical hard ...

  6. 2017ACM暑期多校联合训练 - Team 1 1001 HDU 6033 Add More Zero (数学)

    题目链接 Problem Description There is a youngster known for amateur propositions concerning several math ...

  7. hibernate之关联映射

    No.1 映射一对多双向关联关系: 当类与类之间建立了关联,就可以方便的从一个对象导航到另一个或另一组与它关联的对象. 步骤一: 注意:hibernate要求在持久化类中定义集合类属性时,必须把属性类 ...

  8. C# 小型资源管理器

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  9. 解决WebService 中泛型接口不能序列化问题

    本来要定义WebServices 方法返回一泛型接口集合IList,系统提示不能序列化泛型接口集合  1   [WebMethod]  2         public IList<Employ ...

随机推荐

  1. 什么是PHP7中的孤儿进程与僵尸进程

    什么是PHP7中的孤儿进程与僵尸进程 基本概念 我们知道在unix/linux中,正常情况下,子进程是通过父进程创建的,子进程在创建新的进程.子进程的结束和父进程的运行是一个异步过程,即父进程永远无法 ...

  2. Git最常用的命令 总结

    stage/unstage  git add xxx.xx 和 git reset HEAD xxx.xx 前者将本地的修改提交到index(此操作成为stage,参考备注1),后者将已提交到inde ...

  3. LIS(单调队列优化 C++ 版)(施工ing)

    #include <iostream> using namespace std; #include <cstdio> ; ,x,stack[MaxN]; int main(){ ...

  4. react work with angularjs together

    http://blog.500tech.com/using-reactjs-with-angularjs/ http://www.funnyant.com/reactjs-what-is-it/ ht ...

  5. 20155239 实验四 Android程序设计

    20155239 实验四 Android程序设计 目录 第24章:初识Android 任务一: 完成Hello World, 要求修改res目录中的内容,Hello World后要显示自己的学号 学习 ...

  6. [BZOJ1185][HNOI2007]最小矩形覆盖-[凸包+旋转卡壳]

    Description 传送门 Solution 感性理解一下,最小矩形一定是由一条边和凸包上的边重合的. 然后它就是模板题了..然而真的好难调,小于大于动不动就打错. Code #include&l ...

  7. SaltStack入门篇(七)之架构部署实战

    模块:https://docs.saltstack.com/en/2016.11/ref/states/all/index.html 实战架构图: 实验环境设置: 主机名 IP地址 角色 linux- ...

  8. wpf TabControl控件的SelectionChanged方法

    对于老手来说很简单,但是新手我从百度上找了好久没找到,最后还是去谷歌找到的,哎,万能的google. 前端界面: <TabControl Margin="0,10,0,0" ...

  9. sql异常 获取数据失败的原因及解决方案

    使用dbutils工具类时 不能使用char作为sql的字段类型 报错提示不能转换 所以替换成别的(一般是String)即可

  10. 准备正式开始学习C++,先发点牢骚

    由于职业关系,经常使用AutoCAD之类绘图软件,但这些软件平台的功能,对专业的应用细节来说,并不能全都照顾到,需要一些二次开发,提升一些个性化操作的效率.软件本身也大多提供了开发软件包,AutoCA ...