作业帮 > 英语 > 作业

有关ACM算法的一道题,请各位大牛帮帮忙!

来源:学生作业帮 编辑:百度作业网作业帮 分类:英语作业 时间:2024/05/29 15:31:41
有关ACM算法的一道题,请各位大牛帮帮忙!
Problem - A+B for Input-Output
DescriptionYour task is to calculate the sum of some integers.InputInput contains multiple test cases, and one case one line. Each case starts with an integer N, and then N integers follow in the same line.
OutputFor each test case you should output the sum of N integers in one line, and with one line of output for each line in input.
Sample Input4 1 2 3 4
5 1 2 3 4 5Sample Output10
15
这是题目,我的代码是:
#include
#include
int main()
{
int i,a,b,sum;
scanf("%d",&a);
sum=0;
for(i=0;i
有关ACM算法的一道题,请各位大牛帮帮忙!
这道题属于多组数据输入的,而你的程序只能接受一组数据.
改成这样试试:
#include
#include
int main()
{
int i,a,b,sum;
while(scanf("%d",&a) != EOF){
sum=0;
for(i=0;i