Skip to content

Commit 78108c4

Browse files
author
lanyuanxiaoyao
committed
修改文件: _posts/2014-10-04-as-high-as-ltc.md
1 parent fd4cd0d commit 78108c4

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
layout: post
3+
title: 1407.测试你是否和LTC水平一样高
4+
date: 2014-10-04 01:43
5+
categories: 杭电HDU
6+
tags: [杭电HDU]
7+
---
8+
## Problem
9+
>**Problem Description**
10+
Your task is to Calculate the sum of some integers.
11+
**Input**
12+
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.
13+
**Output**
14+
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.
15+
**Sample Input**
16+
4 1 2 3 4
17+
5 1 2 3 4 5
18+
0
19+
**Sample Output**
20+
10
21+
15
22+
23+
## Solution
24+
```cpp
25+
#include<stdio.h>
26+
int main()
27+
{
28+
int n,i,m,sum;
29+
while((scanf("%d",&n)!=EOF)&&(n!=0))
30+
{
31+
sum=0;
32+
i=1;
33+
while(i<=n)
34+
{
35+
scanf("%d",&m);
36+
{
37+
sum=sum+m;
38+
}
39+
i++;
40+
}
41+
printf("%d\n",sum);
42+
}
43+
return 0;
44+
}
45+
```

0 commit comments

Comments
 (0)