您的位置:首页 > 其它

1069 -- A+B(6)

2015-08-29 17:01 363 查看
A+B(6)
Time Limit:1000MS Memory Limit:65536K

Total Submit:346 Accepted:252
Description
Your task is to calculate the sum of some integers.

Input
Input contains multiple test cases, and one case one line. Each case starts with an integer N, and then N integers follow in the same line.

Output
For each test case you should output the sum of N integers 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

Sample Output
10
15

Source
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace AK1069 {
class Program {
static void Main(string[] args) {
string sb;
while ((sb = Console.ReadLine()) != null) {
string[] s = sb.Split();
int n = int.Parse(s[0]);
//if (n == 0) break;
int sum = 0, i = 1;
while (n-- > 0) {
sum += int.Parse(s[i]);
i++;
}
Console.WriteLine(sum);
}
}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: