您的位置:首页 > 编程语言 > PHP开发

「HD_ACM」A+B for Input-Output Practice (VI)

2015-05-02 21:48 423 查看
Problem 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.

->输入包含多个测试案例,一案一行。每一种情况下,一开始就有一个整数n的n个整数,然后在同一行。

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.

->对于每一个测试案例你应该输出N行整数之和,与一行输入每一行输出。
题目解析

代码解析

#include <stdio.h>
#include <stdlib.h>
int main()
{
int n;
int i;
int k;
int b;
int t;

while(scanf("%d" , &t) != EOF)
{
b=0;

for(i=0;i<t;i++)
{
scanf("%d" , &k);
b+=k;
}
printf("%d\n" ,b);
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: