输入:输入将由一系列整数 n 组成, 每行一个整数。
输出:对于每个案例, 在一行中输出 sum (n), 然后是空行。您可以假定结果将在32位带符号整数的范围内。
#include<stdlib.h>
#include<iostream>
using namespace std;
int main()
{
int a, n;
while ((cin >> n)&&n!=0)
{
int sum = 0;
while (n--)
{
cin >> a;
sum += a;
}
cout << sum << endl;
}
system("pause");
return 0; }