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

学习 时间:2026-04-03 09:35:05 阅读:5312
有关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 45 1 2 3 4 5Sample Output1015 这是题目,我的代码是:#include #include int main(){ int i,a,b,sum; scanf("%d",&a); sum=0; for(i=0;i

最佳回答

呆萌的烤鸡

犹豫的小鸽子

2026-04-03 09:35:05

这道题属于多组数据输入的,而你的程序只能接受一组数据。改成这样试试:#include #include int main(){int i,a,b,sum;while(scanf("%d",&a) != EOF){sum=0;for(i=0;i

最新回答共有2条回答

  • 苹果手链
    回复
    2026-04-03 09:35:05

    这道题属于多组数据输入的,而你的程序只能接受一组数据。改成这样试试:#include #include int main(){int i,a,b,sum;while(scanf("%d",&a) != EOF){sum=0;for(i=0;i

上一篇 英语翻译我不太懂外语..

下一篇 英语翻译中文是:我们已经收到定金2158美元,但是报价单上是2200美元,不过没有关系,到时候我们见面在慢慢谈.我等待你