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的更多相关文章

  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. Java虚拟机创建对象的内存分配以及对象的内存布局

    本博文知识参考周志明<深入理解Java虚拟机> Java虚拟机在创建对象使如果进行内存分配: 1.指针碰撞 2.空闲列表 Java在多线程情况下创建对象的内存分配: Java完成对象内存分 ...

  2. java多线程基本概述(四)——死锁

    package mytask; public class Task { public static void main(String[] args) { DeadThread thread = new ...

  3. C 语言实现字符串替换

    void replaceFirst(char *str1,char *str2,char *str3) { ]; char *p; strcpy(str4,str1); if((p=strstr(st ...

  4. HYML / CSS部分

    1.什么是盒子模型? 在网页中,一个元素占有空间的大小由几个部分构成,其中包括元素的内容(content),元素的内边距(padding),元素的边框(border),元素的外边距(margin)四个 ...

  5. POJ 3261 出现至少K次的可重叠最长子串

    题意就是给一列数字,求最长的一个子串,并且满足子串在原数串中出现至少K次,子串可以重叠. 解法是将问题转为判定性问题,二分子串的长度,判定是否满足重复至少K次.判定方法是经典的根据子串长度将Heigh ...

  6. Java ssh 框架 hibernate 详细理解

    Hibernate框架技术相信对大多数的 java 程序员并不陌生,数据表之间的关系如何通过Hibernate来建立,需要我们认真的分析数据表中数据项之间的交互: 数据库表的之间的关系有: (1)一对 ...

  7. C++STL中map容器的说明和使用技巧(杂谈)

    1.map简介 map是一类关联式容器.它的特点是增加和删除节点对迭代器的影响很小,除了那个操作节点,对其他的节点都没有什么影响.对于迭代器来说,可以修改实值,而不能修改key. 2.map的功能 自 ...

  8. Attribute注解

    class Program { static void Main(string[] args) { //Attribute注解,Attribute是附加到方法.属性.类等上面的特殊的标签,在类Type ...

  9. office web apps 部署-搭建office web apps服务器

    二.搭建office web apps服务器 相关文件可以去焰尾迭分享的百度网盘下载,下载地址:http://pan.baidu.com/s/1o6tCo8y#path=%252Foffice%252 ...

  10. SublimeText3编译JavaScript

    这个操作很简单总的来说分为两步,1.安装Node.js  2.添加SublimeText3 JS编译系统 首先我们去官网下载node.js https://nodejs.org/en/ 然后安装 验证 ...