Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) |
Total Submission(s): 22604 Accepted Submission(s): 15105 |
Problem Description Your task is to calculate the sum of some integers. |
Input Input contains multiple test cases, and one case one line. Each case starts with an integer N, and then N integers follow in the same line. 输入包含多个测试用例,一个用例一行。 每种情况都以整数N开始,然后N个整数跟在同一行中。 |
Output For each test case you should output the sum of N integers in one line, and with one line of output for each line in input. 对于每个测试用例,您应该在一行中输出N个整数的总和,并在输入中输出每行的一行输出。 |
Sample Input 4 1 2 3 4 |
Sample Output 10 |
c++
#include<iostream>
using namespace std;
int main(){
int a,c,sum;
while(cin>>a){
sum=0;
while(a>0){
a--;
cin>>c;
sum=sum+c;
}
cout<<sum<<endl;
}
return 0;
}
运行截图