【ACM】ACM steps 1.1.8

A+B for Input-Output Practice (VIII)

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 40850 Accepted Submission(s): 12244

Problem Description

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 you must note that there is a blank line between outputs.

Sample Input
3
4 1 2 3 4
5 1 2 3 4 5
3 1 2 3

Sample Output
10

15

6

```#include
void main()
{
int n,i,j,t,sum,a,out[1000],q;
sum=0;
scanf(“%dn”,&n);
for (i=0;i<n;i++)
{
scanf(“%d”,&j);
for (t=0;t<j;t++)
{
scanf(“%d”,&a);
sum=sum+a;
out[i]=sum;
}
sum=0;
}
q=n-1;
for (i=0;i<q;i++)
{
printf(“%dnn”,out[i]);
}
printf(“%dn”,out[q]);
}
```

```#include
int main()
{
int a,b,i,j,l[1000],k;
scanf(“%d”,&i);
getchar();
for(j=1;j<=i;j++)
l[j]=0;
for(j=1;j<=i;j++)
{
scanf(“%d”,&a);
getchar();
for(k=1;k<=a;k++)
{
scanf(“%d”,&b);
getchar();
l[j]+=b;
}
}
for(j=1;j<=i-1;j++)
printf(“%dnn”,l[j]);
printf(“%dn”,l[i]);
}
```