作业帮 > 综合 > 作业

一道简单的acm题,可是我老是通不过oj

来源:学生作业帮 编辑:搜搜考试网作业帮 分类:综合作业 时间:2024/06/05 15:55:58
一道简单的acm题,可是我老是通不过oj
Input
Inputcontains multiple test cases, and one case one line. Each case starts with aninteger N, and then N integers follow in the same line.

Output
For each testcase you should output the sum of N integers in one line, and with one line ofoutput for each line in input.
Sample Input
4 1 2 3 4
5 1 2 3 4 5


Sample Output
10
15
一道简单的acm题,可是我老是通不过oj
#include<stdio.h>
 
int main()
{
    int n,x,sum;
    while(scanf("%d",&n)!=EOF)
    {
        sum = 0;
        while(n--)
        {
            scanf("%d",&x);
            sum+=x;
        }
        printf("%d/n",sum);
    }
    return 0;
}学习一下输入输出就好,欢迎交流.
再问: oj也报错,还有你的换行应该是\n
再答: 给个题目网址吧,我试一下。
再问: http://acm.hdu.edu.cn/game/entry/problem/show.php?chapterid=1§ionid=1&problemid=3006
再答: #include<stdio.h>
  
int main()
{
    int n,x,sum;
    while(scanf("%d",&n)!=EOF)
    {
        sum = 0;
        while(n--)
        {
            scanf("%d",&x);
            sum+=x;
        }
        printf("%d\n",sum);
    }
    return 0;
}这个是可以AC的,你试试哈。