Your task is to Calculate the sum of some integers.
InputInput 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.
OutputFor each group of input integers you should output their sum in one line, and with one line of output for each line in input.
SampleInput
4 1 2 3 3 5 1 2 4 4 5 0
Output
9 16
#include#include #include int main() { int n, i, m, sum; while(scanf("%d", &n) != EOF){ sum = 0; for(i = 0; i < n; i++){ scanf("%d", &m); sum += m; } if(n > 0){ printf("%dn", sum); } } return 0; }
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)