acm编程的问题

来源:百度知道 编辑:UC知道 时间:2024/05/03 06:29:52
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

我的程序如下,但不通过,为什么?

#include <stdio.h>
int main()
{
int n, m, a, sum;
scanf("%d\n", &n);
while(n --)
{
scanf("%d", &m);
sum = 0;
while(m --)
{
scanf("%d", &a);
sum += a;
}
printf("%d\n\n", sum);
}
return 0;
}
1楼2楼4楼都无法通过……
网站上提示“Presentation Error”
原题在

刚才通过了的: id: k13795263

````````````````````````````````
#include <stdio.h>

int main ()
{
int m, n, i, sum, temp;
i = 0;
scanf ("%d\n", &n);
while (n --) {
scanf ("%d", &m);
sum = 0;
while (m --){
scanf ("%d", &temp);
sum += temp;
}
if (i == n) {
printf ("%d\n", sum);
}
else {
printf ("%d\n", sum);
printf ("\n");
}
}
return 0;
}

我来回答,好怀念ACM
你英文肯定没学好,这道题目很简单的;

main()
{
int a,b,c,i;
int sum;
while(scanf("%d",&a)!=0)
{
if(scanf("%d",&b)==0) conintue;
else
{
sum=0;
for(i=0;i<b;i++)
{scanf("%d",&c);
sum+=c;
}
printf("%d",sum);
}
}
}

因为题目没对整数大小限制,所以我用了INT 22