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

  1. #include <stdio.h>
  2. int main()
  3. {
  4. int a, b;
  5. while (scanf("%d%d", &a, &b) != EOF)
  6. printf("%d\n", a + b);
  7. return ;
  8. }

C++

C++和C区别不大,仅仅是<stdio.h>和<iostream>,printf和cout,scanf和cin,以及如何判断EOF。

  1. #include <iostream>
  2. int main()
  3. {
  4. int a, b;
  5. while (cin >> a >> b)
  6. cout << (a + b) << endl;
  7. return ;
  8. }

[HDU1000] A + B Problem的更多相关文章

  1. A + B Problem,hdu-1000

    A + B Problem Problem Description Calculate A + B.   Input Each line will contain two integers A and ...

  2. 【HDU1000】A+B Problem

    题目来源:www.acm.hdu.edu.cn 题目编号:1000  A+B Problem /*----------------------------------------原题目-------- ...

  3. A + B Problem(hdu1000)

    注意,认真读题目的Input要求,看看是输入一组测试数据还是输入多组测试数据.输入多组数据,不要忘记while(). #include<iostream> using namespace ...

  4. A+B Problem && OJ推荐【持续更新】

    目录 List 前言 长郡 Position: code 1. 2. 持续更新,么么哒 List 前言 有没有觉得写这篇文章很奇怪,这个还是有原因的.①很多OJ都有着道题,所以发个博客②这可以介绍很多 ...

  5. 1199 Problem B: 大小关系

    求有限集传递闭包的 Floyd Warshall 算法(矩阵实现) 其实就三重循环.zzuoj 1199 题 链接 http://acm.zzu.edu.cn:8000/problem.php?id= ...

  6. 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 ...

  7. C - NP-Hard Problem(二分图判定-染色法)

    C - NP-Hard Problem Crawling in process... Crawling failed Time Limit:2000MS     Memory Limit:262144 ...

  8. Time Consume Problem

    I joined the NodeJS online Course three weeks ago, but now I'm late about 2 weeks. I pay the codesch ...

  9. Programming Contest Problem Types

        Programming Contest Problem Types Hal Burch conducted an analysis over spring break of 1999 and ...

随机推荐

  1. SpringMVC文件上传下载

    不多说,代码: Spring-config.xml<!-- spring可以自动去扫描base-pack下面的包或者子包下面的java文件, 如果扫描到有Spring的相关注解的类,则把这些类注 ...

  2. Linux轻松使用vim

    VIM命令---Vi IMproved, a programmers text editor文本编辑 1>gedit   图形文本编辑工具 2>vim      字符界面的编辑工具 写脚本 ...

  3. linux C/C++ 日志打印函数

    //宏定义日志文件名 #define PROCESSNAME  "log_filename" //当日志文件大于5M时,会删除该文件,该接口使用方法 参照printfvoid Wr ...

  4. 傻瓜式使用AutoFac

    定义一个接口: using System; using System.Collections.Generic; using System.Linq; using System.Web; namespa ...

  5. Google Chrome 默认非安全端口列表

    1, // tcpmux7, // echo 9, // discard 11, // systat 13, // daytime 15, // netstat 17, // qotd 19, // ...

  6. C#并行编程--命令式数据并行(Parallel.Invoke)

    命令式数据并行   Visual C# 2010和.NETFramework4.0提供了很多令人激动的新特性,这些特性是为应对多核处理器和多处理器的复杂性设计的.然而,因为他们包括了完整的新的特性,开 ...

  7. fuse on TDH4.8

    一.安装依赖包 yum install autoconf.noarch yum install automake yum install libtool* yum install m4 yum ins ...

  8. MVC框架中,遇到 [程序集清单定义与程序集引用不匹配]怎么办?

    项目里有一个WinForm程序,它需要使用一套第三方控件.而我的机器上存有这套控件的两种版本(一个是源码版,一个是演示版).结果经常出现“程序集清单定义与程序集引用不匹配的问题”的异常.最要命的是有时 ...

  9. [ext4]010 磁盘布局 - 如何查找inode的磁盘位置

    在linux系统中,任何一个文件,都有一个inode与其对应,也就是说,在一个文件系统中,一个文件都有唯一的ino来标示他,那么在ext4系统中,ino是如何确定的哪? 当我们新创建的文件或目录时,会 ...

  10. 1004 Let the Balloon Rise

    Contest time again! How excited it is to see balloons floating around. But to tell you a secret, the ...