A + B Problem(1000)

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

Problem Description
Calculate A + B.
 
Input
Each line will contain two integers A and B. Process to end of file.
 
Output
For each case, output A + B in one line.
 
Sample Input
1 1
 
Sample Output
2
 
 
题意:每一行输入包含两个整数a和b,每个案例输出a+b的值,在一行;
详见代码,
#include<stdio.h>
int main()
{
int a,b,sum;
while(scanf("%d%d",&a,&b)!=EOF)
{
     sum=a+b;
printf("%d\n",sum);
}
return 0;
}

Sum Problem(1001)

Time Limit: 1000/500 MS (Java/Others)   
Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 237995    Accepted Submission(s): 58229

Problem Description
Hey, welcome to HDOJ(Hangzhou Dianzi University Online Judge).

In this problem, your task is to calculate SUM(n) = 1 + 2 + 3 + ... + n.
 
Input
The input will consist of a series of integers n, one integer per line.
 
Output
For each case, output SUM(n) in one line, followed by a blank line. You
may assume the result will be in the range of 32-bit signed integer.
 
Sample Input
1
100
 
Sample Output
1
 
5050
 
 
 题意:每行将输入一个整数n,对于每个案例,输出SUM(n) = 1 + 2 + 3 +  ... + n<求1到n的和> 在一行,紧随其后的是一个空行。
 
其他的就没什么可以注意的了。
详见代码:
#include<stdio.h>
int main()
{
int n,i,sum; while(scanf("%d",&n)!=EOF)
{
for(sum=0,i=0;i<=n;i++)
sum=sum+i;
printf("%d\n\n",sum);
}
return 0;
}

A+B for Input-Output Practice (I)(1089)

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

Problem Description
Your task is to Calculate a + b. Too easy?! Of course! I specially designed the problem for acm beginners. You must have found that some problems have the same titles with this one, yes, all these problems
were designed for the same aim.
 
Input
The input will consist of a series of pairs of integers a and b, separated by a space, one pair of integers per line.
 
Output
For each pair of input integers a and b you should output the sum of a and b in one line, and with one line of output for each line in input.
 
Sample Input
1 5
10 20
 
Sample Output
6
30
 
题意:输入整数a和b,用空格分隔,每行一对整数。对于每一对输入整数a和b你应该输出他们的总和,输入a和b占在一行,输出占一行。
貌似和1000是一样的,o(∩_∩)o 哈哈!
#include<stdio.h>
int main()
{
int a,b,sum;
while(scanf("%d%d",&a,&b)!=EOF)
{
     sum=a+b;
  printf("%d\n",sum);
}
return 0;
}

A+B for Input-Output Practice (II)(1090)

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

Problem Description
Your task is to Calculate a + b.
 
Input
Input contains an integer N in the first line, and then N lines follow. Each line consists of a pair of integers a and b, separated by a space, one pair of integers per line.
 
Output
For each pair of input integers a and b you should output the sum of a and b in one line, and with one line of output for each line in input.
 
Sample Input
2
1 5
10 20
 
Sample Output
6
30
 
 
题意:输入包含一个整数N在第一行,然后有N数据。每一行包含一对整数a和b,用空格分隔,每行一对整数。
     对于每一对输入整数a和b你应该输出的总和,a和b在一行,输出输入各占一行。
比较1089,在1089的基础上多了一个控制输入测试的组数N,其他的一样。有木有。
详见代码;
#include<stdio.h>
int main()
{
int a,b,t,sum;
scanf("%d",&t);
while(t--)
{
scanf("%d%d",&a,&b);
sum=a+b;
printf("%d\n",sum);
}
return 0;
}

A+B for Input-Output Practice (III)(1091)

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

Problem Description
Your task is to Calculate a + b.
 
Input
Input contains multiple test cases. Each test case contains a pair of integers a and b, one pair of integers per line. A test case containing
0 0 terminates the input and this test case is not to be processed.
 
Output
For each pair of input integers a and b you should output the sum of a and b in one line, and with one line of output for each line in input.
 
Sample Input
1 5
10 20
0 0
 
Sample Output
6
30
 
题意:输入包含多个测试用例。每个测试用例包含一对整数a和b,一对整数占一行。当输入测试用例为0 0时,终止输入和测试用例是不被处理。对于每一对输入整数a和b你应该输出他们的总和,a和b在一行,输出在一行。
 
比较1091,不一样的地方就是结束输入的条件不一样,其他的不变,有木有。
详见代码:
#include<stdio.h>
int main()
{
int a,b,sum;
while(scanf("%d%d",&a,&b)!=EOF)
{
if(a==0&&b==0)break;
sum=a+b;
printf("%d\n",sum); }
return 0;
}

A+B for Input-Output Practice (IV)

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

Problem Description
Your task is to Calculate the sum of some integers.
 
Input
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.
 
Output
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.
 
Sample Input
4 1 2 3 4
5 1 2 3 4 5
0
 
Sample Output
10
15
 
 
题意:输入包含多个测试用例。每个测试用例包含一个整数N,然后在同一行输入N个整数,。当测试用例是0时,终止输入和测试用例是不被处理。每组输出整数之和占一行,即,一行输入一行输出。
 
比较前面几题,这题稍微有点区别但变幻不大,N用来控制整数的个数。然后最后以0结束测试,
 
详见代码:
#include<stdio.h>
int main()
{
int a[100],t,i,sum;
while(scanf("%d",&t)!=EOF)
{
if(t==0)
break;
sum=0;
for(i=1;i<=t;i++)
{
scanf("%d",&a[i]);
sum=sum+a[i];
}
printf("%d\n",sum);
}
return 0;
}

A+B for Input-Output Practice (V)

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

Problem Description
Your task is to calculate the sum of some integers.
 
Input
Input contains an integer N in the first line, and then N lines follow. Each line starts with a integer M, and then M integers follow in the same line.
 
Output
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.
 
Sample Input
2
4 1 2 3 4
5 1 2 3 4 5
 
Sample Output
10
15
 
 
题意:输入包含一个整数N在第一行,然后有N行测试用例,每一行都始于一个整数M,然后有M整数在同一个行。
每组输出整数之和且输出占一行,一行输入一行输出。
 
反思:是不是前两题的集合体哈,再仔细看看就知道了。有木有!
 
详见代码:
#include<stdio.h>
int main()
{
int a[100],t,i,p,sum;
scanf("%d",&p);
while(p--)
{
scanf("%d",&t);
if(t==0)
break;
sum=0;
for(i=1;i<=t;i++)
{
scanf("%d",&a[i]);
sum=sum+a[i];
}
printf("%d\n",sum);
}
return 0;
}

A+B for Input-Output Practice (VI)

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

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
 
 
 
这题就不要在啰嗦的在写题意了吧,貌似和上面的题目太像了,,,,o(∩_∩)o 哈哈
详见代码:
#include<stdio.h>
int main()
{
int a[100],t,i,sum;
while(scanf("%d",&t)!=EOF)
{
sum=0;
for(i=1;i<=t;i++)
{
scanf("%d",&a[i]);
sum=sum+a[i];
}
  printf("%d\n",sum);
}
return 0;
}

看到这里我只想说,大家做题时候,代码写的格式一定要规范,最好就是形式统一,该空的时候就空格,不然代码都一个水平面就美观了,而且以后比赛的时候你还有2个队友,让他们给你检查错误的话,你的代码又不整洁,那么效率肯定不会高的,而且会有厌烦的心态,那就更好了,所以大家以后写代码尽量规范一点。就是这样了!

A+B for Input-Output Practice (VII)

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

Problem Description
Your task is to Calculate a + b.
 
Input
The input will consist of a series of pairs of integers a and b, separated by a space, one pair of integers per line.
 
Output
For each pair of input integers a and b you should output the sum of a and b, and followed by a blank line.
 
Sample Input
1 5
10 20
 
Sample Output
6
 
30
 
 
题意:输入2个整数a和b,用空格分隔,每行一对整数。对于每一对输入整数a和b你应该输出他们的总和,a和b,身后跟着一个空行。
 
是不是又忘记空行了,输出的时候,这次又是中间再空一行哦,所以做题的时候一定要先看清楚题目的具体要求在动手编程,不然只会白白丢分!
 
详见代码:
#include<stdio.h>
int main()
{
int a,b,sum;
while(scanf("%d%d",&a,&b)!=EOF)
{
sum=a+b;
printf("%d\n\n",sum);
}
return 0;
}

终于快结束了,,,,,,搞得好辛苦,大家一定要认真对待啊!

A+B for Input-Output Practice (VIII)

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

Problem Description
Your task is to calculate the sum of some integers.
 
Input
Input contains an integer N in the first line, and then N lines follow. Each line starts with a integer M, and then M integers follow in the same line.
Output
For each group of input integers you should output their sum in one line, and you must note that there is a blank line between outputs.
 
Sample Input
3
4 1 2 3 4
5 1 2 3 4 5
3 1 2 3
 
Sample Output

10

 
15
 
6
 
 
题意:输入包含一个整数N在第一行,然后有N行测试数据。每一行都开始都有一个整数M,然后后面有M个整数在同一行。
每组输出整数之和,输出占一行,你必须注意,输出,每行之间有一个空行。
 
我只能说这题就是上面几道题目的大集合吧,所以是不是很简单呢。哈哈,所以对于acm的输入输出是不是有所了解了呢,
  对!就是那么简单!so
easy!    o(∩_∩)o    那么,,,
 
 
还是先看代码吧,
#include<stdio.h>
int main()
{
int a[100],t,i,p,sum;
scanf("%d",&p);
while(p--)
{
scanf("%d",&t);
sum=0;
for(i=1;i<=t;i++)
{
scanf("%d",&a[i]);
sum=sum+a[i];
}
printf("%d\n",sum);
if(p)//中间空行用
printf("\n");
}
return 0;
}
 

到现在为止,你已经学会acm的简单输入输出了,(当然不是所有的输入输出,这个留给以后慢慢学习好了,)那么现在你已经可以在杭电上A题了,(为自己鼓掌,哈哈),接下来大家可以从简单题下手,本人建议可以先做11页的题。

当然不会的题欢迎到群内讨论,QQ群:  <主要面向刚刚入门的13级新生!>

最后还有一个小小的建议:学习贵在坚持!刚刚开始都是比较难的,所以大家要相互鼓励相互监督,共同进步!

          谢谢你的浏览!o(∩_∩)o

 
转载请注明出处:http://www.cnblogs.com/yuyixingkong/ 自己命运的掌控着!

新手入门 acm 输入输出练习的更多相关文章

  1. 【LaTeX】E喵的LaTeX新手入门教程(5)参考文献、文档组织

    这不是最后一篇,明天开始建模所以会从6号开始继续更新.前情回顾[LaTeX]E喵的LaTeX新手入门教程(1)准备篇 [LaTeX]E喵的LaTeX新手入门教程(2)基础排版 [LaTeX]E喵的La ...

  2. 新手入门指导:Vue 2.0 的建议学习顺序

    起步 1. 扎实的 JavaScript / HTML / CSS 基本功.这是前置条件. 2. 通读官方教程 (guide) 的基础篇.不要用任何构建工具,就只用最简单的 <script> ...

  3. Flume NG Getting Started(Flume NG 新手入门指南)

    Flume NG Getting Started(Flume NG 新手入门指南)翻译 新手入门 Flume NG是什么? 有什么改变? 获得Flume NG 从源码构建 配置 flume-ng全局选 ...

  4. 原创:从零开始,微信小程序新手入门宝典《一》

    为了方便大家了解并入门微信小程序,我将一些可能会需要的知识,列在这里,让大家方便的从零开始学习:一:微信小程序的特点张小龙:张小龙全面阐述小程序,推荐通读此文: 小程序是一种不需要下载.安装即可使用的 ...

  5. 【原创】新手入门一篇就够:从零开发移动端IM

    一.前言 IM发展至今,已是非常重要的互联网应用形态之一,尤其移动互联网时代,它正以无与论比的优势降低了沟通成本和沟通代价,对各种应用形态产生了深远影响. 做为IM开发者或即将成为IM开发者的技术人员 ...

  6. 课程上线 -“新手入门 : Windows Phone 8.1 开发”

    经过近1个月的准备和录制,“新手入门 : Windows Phone 8.1 开发”系列课程已经在Microsoft 虚拟学院上线,链接地址为:http://www.microsoftvirtuala ...

  7. WordPress建站 新手入门

    WordPress建站 新手入门教程系列 1. WordPress入门 之 什么是WordPress? 2. WordPress入门 之 搭建WordPress站点需要什么条件? 3. WordPre ...

  8. 安卓自动化测试(2)Robotium环境搭建与新手入门教程

    Robotium环境搭建与新手入门教程 准备工具:Robotium资料下载 知识准备: java基础知识,如基本的数据结构.语法结构.类.继承等 对Android系统较为熟悉,了解四大组件,会编写简单 ...

  9. mongodb新手入门,mongodb命令学习

    下面来总结一下mongodb新手入门的常用命令吧.要是您是mongodb新手,可以看下. 1,show dbs 查询mongodb里面的数据库列表 如果想查看当前连接在哪个数据库下面,可以直接输入db ...

随机推荐

  1. MongoDB 3.0安全权限访问控制(Windows版)

    MongoDB 3.0安全权限访问控制(Windows版) 1.首先,不使用 –auth 参数,启动 mongoDB: mongod --dbpath "d:\mongodb\data\db ...

  2. [功能帮助类] C# BaseRandom随机数,随机字符,可限制范围-帮助类 (转载)

    点击下载 BaseRandom.rar 主要功能如下 .产生随机字符 .产生随机数 .在一定范围内产生随机数 看下面代码吧 /// <summary> /// 编 码 人:苏飞 /// 联 ...

  3. 使用java的Calendar对象获得当前日期的上几个度开始、结束时间

    思路: 先获得当前季度的开始和结束日期,在当前日期的基础上往前推3个月即上个季度的开始和结束日期 /** * @param flag true:开始日期:false:结束日期 * @return */ ...

  4. BFC探秘

    今天面试被问到了BFC,听到这个缩略词我是懵比的,啥东西?还是太年轻太简单啊.于是面试结束之后搜了几篇博客看了下,看完有一种豁然开朗的感觉,一些之前未能理解的CSS元素行为也知其所以然了.顺便说一下, ...

  5. 删除svn密码方法

    很多时候使用svn,我们需要切换svn账号,但是由于之前的账号已经选择了记住密码,那么我们应该如何删除svn密码来切换新的svn账号呢? 其实很简单,svn账号密码信息保存在电脑某一文件中,我们只要删 ...

  6. JDBC连接池以及动态SQL处理

    复习一下: 1.先创建一个properties配置文件 ClasssName=oracle.jdbc.driver.OracleDriver url=jdbc:oracle:thin:@服务器IP:端 ...

  7. Activity启动过程简要介绍

    无论是通过点击应用程序图标来启动Activity,还是通过Activity内部调用startActivity接口来启动新的Activity,都要借助于应用程序框架层的ActivityManagerSe ...

  8. myeclipse 添加服务器运行时环境

    像servlet-api.jar.servlet-api.jar服务器能提供的包 解决方法如下: 1,File->New->Other->Server->Server(注意在n ...

  9. MySQL驱动阅读------Connection连接的建立,基于JDBC-----5.1.26

    一般获取数据库连接的程序 Class.forName("com.mysql.jdbc.Driver"); final Connection connection = (Connec ...

  10. iOS:等待控件

    定义: @interface ViewController () { UIActivityIndicatorView *testActivityIndicator; } 实例化,开始旋转: -(voi ...