HDU 1094 A+B for Input-Output Practice (VI)(水~)

Description
给出n个数,求和
Input
多组输入,每组用例占一行包括序列长度n以及n个整数表示该序列,以文件尾结束输入
Output
对于每组用例,输出这n个数的和
Sample Input
4 1 2 3 4
5 1 2 3 4 5
Sample Output
10
15
Solution
纯净水
Code

#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        int sum=0,d;
        for(int i=0;i<n;i++)
            cin>>d,sum+=d;
        cout<<sum<<endl;
    }
    return 0;
}

你可能感兴趣的:(HDU 1094 A+B for Input-Output Practice (VI)(水~))