[HDU1000] A + B Problem
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。
但是是多行的,因此需要用循环反复读取。
又因为输入数据中没有说有多少行,因此不能使用计数循环,而要通过while循环判断是否到达文件尾,如果是则停止循环。
而在循环中则是将输入的两个数的和算出,并输出。
因此C/C++代码如下:
C
#include <stdio.h>
int main()
{
int a, b;
while (scanf("%d%d", &a, &b) != EOF)
printf("%d\n", a + b);
return ;
}
C++
C++和C区别不大,仅仅是<stdio.h>和<iostream>,printf和cout,scanf和cin,以及如何判断EOF。
#include <iostream>
int main()
{
int a, b;
while (cin >> a >> b)
cout << (a + b) << endl;
return ;
}
[HDU1000] A + B Problem的更多相关文章
- A + B Problem,hdu-1000
A + B Problem Problem Description Calculate A + B. Input Each line will contain two integers A and ...
- 【HDU1000】A+B Problem
题目来源:www.acm.hdu.edu.cn 题目编号:1000 A+B Problem /*----------------------------------------原题目-------- ...
- A + B Problem(hdu1000)
注意,认真读题目的Input要求,看看是输入一组测试数据还是输入多组测试数据.输入多组数据,不要忘记while(). #include<iostream> using namespace ...
- A+B Problem && OJ推荐【持续更新】
目录 List 前言 长郡 Position: code 1. 2. 持续更新,么么哒 List 前言 有没有觉得写这篇文章很奇怪,这个还是有原因的.①很多OJ都有着道题,所以发个博客②这可以介绍很多 ...
- 1199 Problem B: 大小关系
求有限集传递闭包的 Floyd Warshall 算法(矩阵实现) 其实就三重循环.zzuoj 1199 题 链接 http://acm.zzu.edu.cn:8000/problem.php?id= ...
- No-args constructor for class X does not exist. Register an InstanceCreator with Gson for this type to fix this problem.
Gson解析JSON字符串时出现了下面的错误: No-args constructor for class X does not exist. Register an InstanceCreator ...
- C - NP-Hard Problem(二分图判定-染色法)
C - NP-Hard Problem Crawling in process... Crawling failed Time Limit:2000MS Memory Limit:262144 ...
- Time Consume Problem
I joined the NodeJS online Course three weeks ago, but now I'm late about 2 weeks. I pay the codesch ...
- Programming Contest Problem Types
Programming Contest Problem Types Hal Burch conducted an analysis over spring break of 1999 and ...
随机推荐
- metools,不花一分钱就能拥有自己的工具站点?
需要[加密/解密][编码/解码][生成二维码]的时候不用再进百度点广告~ 也不需要去收藏夹找网址~ 我的目的大概就是如此. 项目地址:https://github.com/yimogit/metool ...
- Html 经典布局(一)
经典布局案例(一): <!DOCTYPE html> <html lang="en"> <head> <meta charset=&quo ...
- 【linux 爱好者群】程序猿的那些聊天记录
分享&&交流&&开放 you should get it 声明:好吧,我们的群只有5个人,但是有句话不是说的很对吗,一个项目最理想的不就是5个人么.我是写文本那个. 下 ...
- struts2 之 struts2类型转换
1. 在struts2中,相比servlet来时,获取数据时,程序员没有进行手动的类型转换,类型转换工作都有struts2来完成处理,但愿对于自定义类型数据,struts2不会帮助我们完成类型转换工作 ...
- 基于 Haproxy 构建负载均衡集群
1.HAPROXY简介 HAProxy提供高可用性.负载均衡以及基于TCP和HTTP应用的代理,支持虚拟主机,它是免费.快速并且可靠的一种负载均衡解决方案.HAProxy特别适用于那些负载特大的web ...
- Java工程中使用Mybatis (工程结合Mybatis,数据可以结合Swing使用)
2011年6月iBatis 更名为 MyBatis,从 iBatis 到 MyBatis,不只是名称上的变化,MyBatis 提供了更为强大的功能,同时并没有损失其易用性,相反,在很多地方都借助于 J ...
- 金山助手流氓软件-被进程sjk_daemon.exe坑死
修改完Android工程代码,进入调试阶段时DDMS中报错:The connection to adb is down, and a severe error has occured. 由于之前也碰到 ...
- 在Mvc中进行异步请求是出现(没有为该对象定义无参数的构造函数)
解决办法就是给相应的类添加无参数的构造函数:
- 1019 Least Common Multiple
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission( ...
- grep与正则表达式
grep的作用:文本搜索工具,根据用户指定的"模式"对目标文件逐行进行匹配检查:打印匹配到的行. 模式:正则表达式编写的过滤条件. 正则表达式(REGEXP):由一类特殊字符及文本 ...