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

U - A+B for Input-Output Practice (IV),第1张

U - A+B for Input-Output Practice (IV) 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 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;
}

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5702393.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-17
下一篇 2022-12-17

发表评论

登录后才能评论

评论列表(0条)

保存