A+B for Input-Output Practice (V)

谁都会走 提交于 2020-03-11 09:50:25

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

Author

lcy
代码:

#include<stdio.h>
int main()
{
	int a,b,n;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a);
		int sum=0;
		for(int j=0;j<a;j++){
			scanf("%d",&b);
			sum+=b;
		}
		printf("%d\n",sum);
		
	}
    return 0;
}

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!