南邮 OJ 1087 A + B Problem (4)

比赛描述

Calculate the sum of some integers.



输入

The input will consist of multiple test cases. Each test case consist of an integer N and then N integers following in the same line,separated by a space. A line starting with 0 terminates the input and this line is not to be processed.

输出

For test case, you should output their sum in one line, and with one line of output for each line in input. After each test case output, you should output one blank line.

样例输入

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

样例输出

10

15

题目来源

HDUOJ



//每一行后面都要有空行
#include<stdio.h>
int main(){
	int N,a,sum;
	while(scanf("%d",&N) && N){
		sum = 0;
		while(N--){
			scanf("%d",&a);
			sum += a;
		}
		printf("%d\n\n",sum);
	}
}






你可能感兴趣的:(ACM,+,problem,4,B,a,南邮OJ)