杭电1092(坚持着,总有一天,你会站在最亮的地方)

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

问题描述

你的任务是计算a + b。

输入

输入包含多个测试用例。每个测试用例包含两个整数a和b,每行一对整数。测试用例包含0 0终止输入和这个测试用例不是要处理。

输出

对于每一对输入整数a和b,你应该输出的总和a和b在一行,和一行输出输入的每一行。

样例输入

1 5

10 20

0 0

#include<stdio.h>

int main()
{
int a,sum=0,n;
scanf("%d",&n);
while(n!=0) {
for(int i=0; i<n; i++) {
scanf("%d",&a);
sum = sum+a;
}
printf("%d\n",sum);
sum = 0;
scanf("%d",&n);
}
return 0;
}

 

 

posted on 2015-04-20 19:37  Randy77  阅读(334)  评论(0编辑  收藏  举报

导航