杭电ACM刷题(2)

输入:输入将由一系列整数 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;  }

猜你喜欢

转载自blog.csdn.net/qq_42659468/article/details/88371798
今日推荐