关闭

hdoj A+B for Input-Output Practice (IV)

120人阅读 评论(0) 收藏 举报
分类:

Problem Description

Your task is to Calculate the sum of some integers.

Input

Input contains multiple test cases. Each test case contains a integer N, and then N integers follow in the same line. A test case starting with 0 terminates the input and this test case is not to be processed.

Output

For each group of input integers you should output their sum in one line, and with one line of output for each line in input.

Sample Input

4 1 2 3 4
5 1 2 3 4 5
0 

Sample Output

10
15
代码:
#include<stdio.h>
int main()
{
    int n,a,sum=0;
    while(scanf("%d",&n)&&n)
    {
        while(n--)
        {
        scanf("%d",&a);
           sum=sum+a;
       }
           printf("%d\n",sum);
           sum=0;
   }
   return 0; 
}
注意:题目要求n=0时结束
0
0
查看评论

「HD_ACM」A+B for Input-Output Practice (IV)

Problem Description Your task is to Calculate the sum of some integers. ->你的任务是计算一些整数相加   Input Input contains multiple...
  • Simple_Bottle
  • Simple_Bottle
  • 2015-05-02 21:26
  • 934

[水题][hdoj_1092]A+B for Input-Output Practice (IV)

// hdoj_1092 A+B for Input-Output Practice (IV) #include int main(void) { int a, n, i, sum; while(scanf("%d", &n) && n != ...
  • litiouslove
  • litiouslove
  • 2012-07-31 01:06
  • 2046

HDU-1092-A+B for Input-Output Practice (IV)(继续!)

A+B for Input-Output Practice (IV) Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Sub...
  • qq_16542775
  • qq_16542775
  • 2015-07-15 14:08
  • 1335

[水题][hdoj_1096]A+B for Input-Output Practice (VIII)

// hdoj_1096 A+B for Input-Output Practice (VIII) #include int main(void) { int n, m, a, sum, i, j; scanf("%d", &n); for(i = 0; ...
  • litiouslove
  • litiouslove
  • 2012-07-31 01:42
  • 3354

hdoj A+B for Input-Output Practice (V)

Problem Description Your task is to calculate the sum of some integers. Input Input contains an integer N in the first line, and then N lines fol...
  • zhaihao1996
  • zhaihao1996
  • 2015-11-20 18:13
  • 272

[水题][hdoj_1094]A+B for Input-Output Practice (VI)

// hdoj_1094 A+B for Input-Output Practice (VI) #include int main(void) { int n, a, sum, i; while(scanf("%d", &n) != EOF) { sum =...
  • litiouslove
  • litiouslove
  • 2012-07-31 01:20
  • 2414

杭电ACM 1089 A+B for Input-Output Practice (I)

A+B for Input-Output Practice (I) Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission...
  • neuxxm
  • neuxxm
  • 2012-11-12 00:54
  • 1729

「HD_ACM」A+B for Input-Output Practice (VII)

Problem Description Your task is to Calculate a + b. ->你的任务是计算A + B   Input The input will consist of a series of ...
  • Simple_Bottle
  • Simple_Bottle
  • 2015-05-02 21:59
  • 1780

杭电ACM 1090 (A+B for Input-Output Practice (II))

#include using namespace std; int main() { int n,a,b,c; cin>>n; for(int i=0;i<n;i++) { cin>>a>>...
  • hjl243632044
  • hjl243632044
  • 2012-01-21 19:22
  • 1296

「HD_ACM」 A+B for Input-Output Practice (II)

Problem Description Your task is to Calculate a + b. ->你的任务是计算A + B   Input Input contains an integer N in the fir...
  • Simple_Bottle
  • Simple_Bottle
  • 2015-05-01 22:41
  • 1659
    个人资料
    • 访问:39565次
    • 积分:2787
    • 等级:
    • 排名:第15170名
    • 原创:248篇
    • 转载:13篇
    • 译文:0篇
    • 评论:4条