A+B for Input-Output Practice (V)

二次信任 提交于 2020-03-11 12:51:29

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

#include <stdio.h>
int main(void)
{
	int t,n,number,s=0;
	scanf("%d",&t);//数据组数
	while(t--)
	{
		s = 0;//总和归0
		scanf("%d",&n);//数据个数
		while(n--)
		{
			scanf("%d",&number);
			s+=number;	
		}	
		printf("%d\n",s);
	}	
	return 0;
} 
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!