A+B problem(4) 南郵ACM的OJ

/***********************************************
A + B Problem (4)
描述

Calculate the sum of some integers.

輸入

The input will consist of multiple test cases. Each test case consist of an integer N and then N integers following in the same line,separated by a space. A line starting with 0 terminates the input and this line is not to be processed.

輸出

For test case, you should output their sum in one line, and with one line of output for each line in input. After each test case output, you should output one blank line.

樣例輸入

4 1 2 3 4
5 1 2 3 4 5
0

樣例輸出

10

15

************************************************************/

#include <iostream>
//#include <fstream>
using namespace std;
int main()
{
// ifstream cin("1.txt");
 int n,i,sum=0;
 int temp;
 cin>>n;
 while(n!=0)
 {
  for(i=0;i<n;i++)
  {
   cin>>temp;
   sum+=temp;
  }
  cout<<sum<<"/n"<<endl;
  sum=0;
  cin>>n;
 }
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章