A+B for Input-Output Practice (VIII) 为什么 我在 杭电 上 做是 Presentation Error!
ProblemDescriptionYourtaskistocalculatethesumofsomeintegers.InputInputcontainsaninteg...
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 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
Author
lcy
Recommend
JGShining
#include<stdio.h>
int main( )
{
int a,b,i,j,m,n;
while(scanf("%d",&n)!=EOF)
{
for(j=0;j<n;j++)
{
b=0;
scanf("%d",&m);
for(i=0;i<m;i++)
{
scanf("%d",&a);
b=b+a;
}
printf("%d\n\n",b);
}
}
return 0;
} 展开
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 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
Author
lcy
Recommend
JGShining
#include<stdio.h>
int main( )
{
int a,b,i,j,m,n;
while(scanf("%d",&n)!=EOF)
{
for(j=0;j<n;j++)
{
b=0;
scanf("%d",&m);
for(i=0;i<m;i++)
{
scanf("%d",&a);
b=b+a;
}
printf("%d\n\n",b);
}
}
return 0;
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询