hdu 2162 Add ‘em
2014-07-28 12:06
141 查看
[align=left]Problem Description[/align]
Write a program to determine the summation of several sets of integers.
[align=left]Input[/align]
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.
[align=left]Output[/align]
A single line of output should be generated for each set of integers. The line should have format shown below.
[align=left]Sample Input[/align]
[align=left]Sample Output[/align]
[/code]
Write a program to determine the summation of several sets of integers.
[align=left]Input[/align]
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.
[align=left]Output[/align]
A single line of output should be generated for each set of integers. The line should have format shown below.
[align=left]Sample Input[/align]
4 -1 3 1 1 2 19 17 5 -645 952 -1488 -5456 -9342 -1
[align=left]Sample Output[/align]
Sum of #1 is 4 Sum of #2 is 36 Sum of #3 is -15979[code]#include<stdio.h> int main() { int n,m; int sum; int a,i; m=1; while(scanf("%d",&n),(n>0)) { sum=0; for(i=0;i<n;i++) { scanf("%d",&a); sum+=a; } printf("Sum of #%d is %d\n",m++,sum); } return 0; }
[/code]
相关文章推荐
- JAVA hdu 2162 Add ‘em
- hdu 2162 Add ‘em
- hdu-2162-Add ‘em
- HDOJ(HDU) 2162 Add ‘em(求和)
- HDOJ(HDU) 2162 Add ‘em(求和)
- HDOJ 2162 Add ‘em(水题)
- 杭电acm 2162 Add ‘em
- Add ‘em hdoj2162
- Add ‘em 2162
- 2017 Multi-University Training Contest - Team 1 HDU 6033 Add More Zero【对数】
- (数学)HDU 6033 Add More Zero
- HDU 6033 Add More Zero (数学)
- hdu 2162
- HDU 6033 Add More Zero - 2017多校联盟1 A题
- hdu 6033 Add More Zero
- 17暑假多校联赛1.1 HDU 6033 Add More Zero
- HDU 6033 Add More Zero
- HDU 1166 敌兵布阵(线段树:单点add,区间求和)
- HDU-多校训练赛-Add More Zero
- HDU 6033 Add More Zero(取对数)