Problem Description
Your task is to calculate the sum of some integers.
Input
Input contains an integer N in the first line, and then N lines follow. Each line starts with a integer M, and then M integers follow in the same line.
Output
For each group of input integers you should output their sum in one line, and with one line of output for each line in input.
Sample Input
2
4 1 2 3 4
5 1 2 3 4 5
Sample Output
10
15
我用C++写的程序,请高手修改一下,我就是那个输入不懂怎么写,并说明下思路,谢谢各位了
#include "iostream"
using namespace std;
int main()
{
int N,M;
int i;
cin>>N;
while(N--)
{
int sum=0;
cin>>M;
for(i=0;i<=M;i++)
{
sum+=i;
}
cout<<sum<<endl;
}