Total Submission(s) : 6 Accepted Submission(s) : 6
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 Input2
4 1 2 3 4
5 1 2 3 4 5
Sample Output10
15
问题描述
你的任务是计算一些整数的和。
输入输入在第一行中包含一个整数N,然后后面有N行。
每一行以一个整数M开头,然后在同一行中有M个整数。
输出对于每组输入整数,您应该将它们的和输出到一行中,并为输入中的每一行输出一行。
代码如下
#include<stdio.h>
int main()
{
int n,m,a,sum;
int i;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d",&m);
sum=0;
while(m–){
scanf("%d",&a);
sum+=a;
}
printf("%d\n",sum);
sum=0;
}
return 0;
}