一道简单的acm题,可是我老是通不过oj
来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/10/04 03:41:02
一道简单的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
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
#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的,你试试哈。
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的,你试试哈。
一道简单的acm题,可是我老是通不过oj
一道简单的ACM题目,快速排序的,老是提交不成功,大家帮我看看
一道很简单的ACM题,求大神看看我错在哪儿了,C++
求助一道ACM题一道很简单的ACM题目,题在这里我写的代码如下:#include using namespace std
ACM的一道题,看着很简单,提交却WA了,
ACM OJ上的题目1013:Counterfeit Dollar
求一道acm的题:给你一个文件里面有71k的数字,要你把这些数字压缩之后交上去,这是哪个oj的题啊?
c++ ACM的一道题!
一道简单的acm习题,为什么我的程序没有输出?
ACM一道算法题,我的算法为何WA
acm wrong answer是由什么引起的?北邮一道简单的减法题:
一道很简单的ACM编程题,新人,帮忙看下哪儿错了,