请计算下面每行数的和。
Input
第一行有一个整数N,表示有N行数。接下来N行,每行第一个为整数M,表示本行后面有M个整数。
Output
对于输入的每一行数,请分别对应输出每一行数的和。
Sample Input
2
4 1 2 3 4
5 1 2 3 4 5
Sample Output
10
15
Hint
本题相关知识:输入输出和循环语句(for)的使用方式。
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
int n,sum,i;
int a,m,j;
while(scanf("%d", &n) !=EOF)
{
if(n==0)
break;
for( i=0;i<n;++i)
{
sum=0;
scanf("%d",&m);
for(j=0;j<m;j++)
{
cin>>a;
sum+=a;
}
printf("%d\n",sum);
}
}
return 0;
}