博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ACM HDU 1094
阅读量:6980 次
发布时间:2019-06-27

本文共 900 字,大约阅读时间需要 3 分钟。

A+B for Input-Output Practice (VI)

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 75228    Accepted Submission(s): 50441

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.
 
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
 
解题思路:和前几道题没有什么太大区别,还是求累加和,把程序改一下就好。
代码如下:
#include <stdio.h>
int
main
(
void
)
//1092
{
    int
a
;
    int
i
, sum
;
    int
n
;
    while
(scanf_s
(
"%d"
, &n
) != EOF
)
    {
       
       
            sum
=
0
;
            for
(i
=
0
; i
< n
; i
++)
            {
                scanf_s
(
"%d"
, &a
);
                sum
+= a
;
            }
            printf
(
"%d\n"
, sum
);
   
   
   
    }
    return
0
;
}

转载于:https://www.cnblogs.com/WLHBlog/p/7566639.html

你可能感兴趣的文章
阿里巴巴开源技术汇总:115个软件(一)
查看>>
ios开发之系统信息
查看>>
遮罩效果的实现
查看>>
Android之NDK开发的简单实例
查看>>
日志分析工具splunt
查看>>
元素宽高的获取
查看>>
SQLSERVER存储过程基本语法使用
查看>>
sql server时间转换
查看>>
CDH大数据集群安全风险汇总
查看>>
数据结构实验之链表一:顺序建立链表
查看>>
docker Rails Permission denied @ dir_s_mkdir
查看>>
【二分答案】【最短路】bzoj1614 [Usaco2007 Jan]Telephone Lines架设电话线
查看>>
【贪心】Google Code Jam Round 1A 2018 Waffle Choppers
查看>>
【转载】【贪心】各种覆盖问题
查看>>
HDU 6051 - If the starlight never fade | 2017 Multi-University Training Contest 2
查看>>
insert into与insert ignore以及replace into的区别
查看>>
【网络流24题】最小路径覆盖问题
查看>>
java分享第五天(数组)
查看>>
数组与纠结的排序篇
查看>>
Linux命令-安装zip和unzip命令
查看>>