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. powershell入门教程-v0.3版

    powershell入门教程-v0.3版 来源 https://www.itsvse.com/thread-3650-1-1.html 参考 http://www.cnblogs.com/piapia ...

  2. CSS三大特性(继承、优先级、层叠)之个人见解

    首先声明一下CSS三大特性——继承.优先级和层叠.继承即子类元素继承父类的样式,比如font-size,font-weight等f开头的css样式以及text-align,text-indent等t开 ...

  3. java字符串 64位编码

    byte[] encodeBase64 = Base64.encodeBase64("到了是是是是".getBytes("UTF-8")); System.ou ...

  4. USACO_1.1_Greedy_Gift_Givers_(模拟+水题)

    描述 http://train.usaco.org/usacoprob2?a=y0SKxY0Kc2q&S=gift1 给出不超过$10$个人,每个人拿出一定数量的钱平分给特定的人,求最后每个人 ...

  5. Kali 1.0 / 2.0 安装中文输入法(谷歌pinyin + 其他)

    1.kali默认是没有中午输入法的,需要自己安装一下 2.首先我们先获取root权限 dnt@HackerKali:~$ su密码: 3.安装中文输入法(apt-get 指令不会的同学可以学习一下基础 ...

  6. 单源最短路模板_SPFA_Dijkstra(堆优化)_C++

    随手一打就是标准的SPFA,默认1号节点为出发点,当然不用 f 判断是否在队里也可以,只是这样更优化一点 void spfa() { int i,x,k; ;i<=n;i++) { d[i]=o ...

  7. unicode字符串解码显示

    # encoding: utf-8 ''' unicode字符串解码显示 ''' import sys reload(sys) sys.setdefaultencoding('utf-8') a = ...

  8. [Leetcode Week2]Sort Colors

    Sort Colors题解 原创文章,拒绝转载 题目来源:https://leetcode.com/problems/sort-colors/description/ Description Give ...

  9. HDU 4344 大数分解大素数判定

    这里贴个模板吧.反正是不太理解 看原题就可以理解用法!! #include <cstdio> #include <iostream> #include <algorith ...

  10. libyuv编译【转】

    转自:http://blog.csdn.net/kl222/article/details/41309541 版权声明:本文为博主原创文章,未经博主允许不得转载. 下载代码(要FQ): git clo ...