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. Python实现注册和三次验证登录

    # 帐户表account:# sylar:123# alex:456# wusir:789# taibai:789# 需熟练的知识点:文件操作with open()/write()/read().去掉 ...

  2. 《你不知道的JavaScript》系列分享专栏

    <你不知道的JavaScript>系列分享专栏 你不知道的JavaScript”系列就是要让不求甚解的JavaScript开发者迎难而上,深入语言内部,弄清楚JavaScript每一个零部 ...

  3. Python学习之——Oracle数据库连接

    一.安装Oracle客户端 1.下载对应安装文件,官网地址:http://www.oracle.com/technetwork/database/database-technologies/insta ...

  4. node.js之express中app.use

    express中app.use 用法: app.use([path,] function [, function…]) 一.app.use() 在express中是怎么工作的 app.use在expr ...

  5. Flex copy and paste

    <?xml version="1.0" encoding="utf-8"?> <mx:WindowedApplication xmlns:mx ...

  6. 移除VS解决方案和TFS服务器的关系

    有时候会遇到服务器IP服务器变更,甚至TFS服务器坏了,或者将项目重新上传至新的TFS区: 可以使用notepad之类的软件打开解决方案(.sln文件),删掉类似下面的部分: GlobalSectio ...

  7. combobox添加复选框

    问题: 需求提出要做一个下拉框可以多选的 解决方案: //机构树 function initOrgTree() { $('#reportOrg').combobox({ width: 200, edi ...

  8. Linux无法su到普通用户

    无法通过su命令登录到普通用户 [root@linux-server ~]# su - tomcat su: cannot set user id: Resource temporarily unav ...

  9. OpenStack入门篇(二)之OpenStack架构

    1.OpenStack 架构 中间菱形是虚拟机,围绕 VM 的那些长方形代表 OpenStack 不同的模块(OpenStack 叫服务,后面都用服务这个术语),下面来分别介绍. Nova:管理 VM ...

  10. ESP8266 station模式下建立client、server TCP连接

    程序实现内容: 1.在station模式下,ESP8266作为client.server进行TCP连接2.实现数据的发送.接收(同时回传)实现思路:TCP网络通信分层为:应用层.网络层.数据链路层.物 ...