Add ‘em

Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 4144    Accepted Submission(s): 2976

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 <iostream>
#include<cstdio>
using namespace std; int main()
{
int t,a,sum,c=1;
while(~scanf("%d",&t))
{
if(t<=0)
break;
sum=0;
//c=1;//注意位置,不是这里初始化!
while(t--)
{
scanf("%d",&a);
sum+=a;
}
printf("Sum of #%d is %d\n",c++,sum);
}
return 0;
}

  

 

HDU 2162(注意初始化位置!)的更多相关文章

  1. 关于C++中static初始化位置

    编译原理作业中关于static的初始化位置问题: 在.h文件中这样声明了一个静态数据成员 class Expression { private: static std::vector<Ident ...

  2. WinForm------窗体初始化位置的显示

    在窗体的构造方法里面添加 public Form2() { InitializeComponent(); //指定窗口初始化时的位置(计算机屏幕中间) this.StartPosition = For ...

  3. HDU 2162 Add ‘em

    http://acm.hdu.edu.cn/showproblem.php?pid=2162 Problem Description Write a program to determine the ...

  4. javascript变量初始化位置

    变量在之前<script type="text/javascript"></script>(或引用的js文件)中初始化,可以正常访问. 运行程序:弹出123 ...

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

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

  6. Android模拟位置信息

    Android模拟位置程序,俗称GPS欺骗,只能修改采用GPS定位的软件. 手机定位方式目前有4种:基站定位,WIFI定位,GPS定位,AGPS定位 常见的修改手法: 1. 抓包欺骗法,抓包改包欺骗服 ...

  7. c++ RAII 资源管理就是初始化

    RAII:(Resource Acquisition Is Initialization),也就是“资源获取就是初始化”,是C++语言的一种管理资源.避免泄漏的惯用法.C++标准保证任何情况下,已构造 ...

  8. HDU 2164(模拟)

    Rock, Paper, or Scissors? Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Jav ...

  9. HDU 1010 Tempter of the Bone heuristic 修剪

    的问题是,在测试修剪. 应该说是更先进的应用. 由于使用的heuristic(经验)修剪.总结这方面的经验法则,别easy.我说,这也是由于先进的在线报告中的应用程序没有分析太多太好的解决这个问题,计 ...

随机推荐

  1. 【bzoj1787】[Ahoi2008]Meet 紧急集合 倍增LCA

    题目描述 输入 输出 样例输入 6 4 1 2 2 3 2 4 4 5 5 6 4 5 6 6 3 1 2 4 4 6 6 6 样例输出 5 2 2 5 4 1 6 0 题解 倍增LCA 首先有集合点 ...

  2. vim配置入门,到豪华版vim配置

    这几天一直研究vim的配置,许多版本总是不尽如人意,网上确实有许多优秀的文章值得参考,我的博客后面会贴上具有参考价值的博客链接,本文的将手把手教你配置一个功能详尽的vim. 首先你要明白的是linux ...

  3. input checkbox 多选 验证

    # input checkbox 多选 验证``` <ul class="orderMsg_radio"> <!--单选--> <input valu ...

  4. JQuery中的each()的使用

    each()函数是基本上所有的框架都提供了的一个工具类函数,通过它,你可以遍历对象.数组的属性值并进行处理. jQuery和jQuery对象都实现了该方法,对于jQuery对象,只是把each方法简单 ...

  5. 使用UMeditor富文本编辑器上传图片

    注:本文系作者原创,但可随意转载. 最近写自己的网站玩儿,写到博客的部分,打算使用UMeditor,因为之前也用过(但是好像没实现图片上传的功能),感觉用起来还比较简单. 不过还是折腾了一下午...遇 ...

  6. 表单元素 disabled 和 readonly 辨析

    正确答案: B D 分析: Readonly 和 Disabled 是用在表单中的两个属性,它们都能够做到使用户不能够更改表单域中的内容.但是它们之间有着微小的差别,总结如下: 1)Readonly只 ...

  7. Java并发(9)- 从同步容器到并发容器

    引言 容器是Java基础类库中使用频率最高的一部分,Java集合包中提供了大量的容器类来帮组我们简化开发,我前面的文章中对Java集合包中的关键容器进行过一个系列的分析,但这些集合类都是非线程安全的, ...

  8. [USACO1.3]虫洞

    Luogu链接 题目描述 农夫约翰爱好在周末进行高能物理实验的结果却适得其反,导致N个虫洞在农场上(2<=N<=12,n是偶数),每个在农场二维地图的一个不同点. 根据他的计算,约翰知道他 ...

  9. kafka+flume+HDFS日志采集项目框架

    1,项目图如下: 2, 实现过程 启动HDFS: sbin/start-dfs.sh 启动zookeeper(三台): bin/zkServer.sh start 启动kafka(三台): root@ ...

  10. Codeforces 542C - 漫长艰辛的解题历程

    尽管在下面的一部分解题的方法都有问题... 但是每一次重新提交都是打了一个有意义的补丁的呢 可见在我做题的过程中有多少问题存在... 现在想想,类似于是变量没有开int64,过程函数忘开int64.. ...