一道简单的acm题,可是我老是通不过ojInputInputcontains multiple test cases, and one case one line. Each case starts with aninteger N, and then N integers follow in the same line. OutputFor each testcase you should output the sum of N inte
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/28 20:31:51
一道简单的acm题,可是我老是通不过ojInputInputcontains multiple test cases, and one case one line. Each case starts with aninteger N, and then N integers follow in the same line. OutputFor each testcase you should output the sum of N inte
一道简单的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题,可是我老是通不过ojInputInputcontains multiple test cases, and one case one line. Each case starts with aninteger N, and then N integers follow in the same line. OutputFor each testcase you should output the sum of N inte
#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;
}
学习一下输入输出就好,欢迎交流.