1135:0 start-up algorithm 42--multiple sets of test data (summation) IV

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.