1135:0 start-up algorithm 42--multiple sets of test data (summation) IV time limit:1 Sec Memory limit:64 MB 64bit IO Format:%lld
submitted:2439 accepted:1277
[Submit] [Status] [Web Board] Description
There are a number of inputs are the combination of the above several cases, depending on the topic of the previous situation of the combination
For example, the title requirement is multiple sets of test data
Each set of test data is first entered an integer n (if n=0 is the end) and then n integers are entered
The input format for this type of topic is as follows:
int main ()
{
int n,i;
while (scanf ("%d", &n)!=eof && n!=0)
{
for (i=1;i<=n;i++)
....//input A number at a time, the total cycle n times, need to do other processing
}
}
}
Input
Input contains multiple test cases. Each test case is contains a integer n, and then n integers follow on the same line. A test case, starting with 0 terminates, the input and this test are not processed.
Output
For each group of the input integers you should output their sum on one line, and with one line of output for each line in INP Ut.
Sample Input
4 1 2 3 45 1 2 3 4 50
Sample Output
1015
Source
0 Starting point Learning algorithm
1#include <stdio.h>2 intMain () {3 intN;4 while(SCANF ("%d", &n)!=eof&&n!=0){5 inta,s=0;6 for(intI=1; i<=n;i++){7scanf"%d",&a);8s+=A;9 }Tenprintf"%d\n", s); One } A return 0; -}
1135:0 start-up algorithm 42--multiple sets of test data (summation) IV