oj最简单的题目

来源:百度知道 编辑:UC知道 时间:2024/05/28 06:10:09
Problem Description
Your task is to Calculate the sum of some integers.

Input
Input contains multiple test cases. Each test case contains a integer N, and then N integers follow in the same line. A test case starting with 0 terminates the input and this test case is not to be processed.

Output
For each group of input integers you should output their sum in one line, and with one line of output for each line in input.

Sample Input
4 1 2 3 4
5 1 2 3 4 5
0

Sample Output
10
15

我写的 :
#include<stdio.h>
int main()
{
int a,n,sum;
while(scanf("%d",&n),n)
{
while(n--)
{
scanf("%d",&a);
sum+=a;
}
printf("%d\n",sum);
}
return 0;
}
sum=0;
赋值后还是不行

按你说的加sum没过啊~~出现Time Limit Exceeded 用结构体的那个过了~可是为什么我的不行呢?

最简单的数学题目 pascal最简单的题目 勾股定理的题目(最简单的) 求最简单的一元二次方程题目? 一道最简单的题目..很急 六年级最简单的数学题目 哎~~~~~无聊~~~~一道最简单的科学题目~~~~~送分 一些法律最简单的题目~~~帮忙吖 简单的题目 一道简单的题目