简单题:Your task is to Calculate a + b.
来源:互联网 发布:51电子单片机原理图 编辑:程序博客网 时间:2024/06/06 21:40
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
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
#include<iostream>#include<stdio.h>using namespace std;int main(void){int n,x,y;scanf("%d",&n);while(n--){if(scanf("%d%d",&x,&y)!=EOF)printf("%d\n",x+y);}return 0;}
如果输入的终止条件不是n,而是输入了0 0,那么代码就变成了下面这样:
#include<iostream>#include<stdio.h>using namespace std;int main(void){int x,y;while(scanf("%d%d",&x,&y) &&(x!=0 || y!=0)){printf("%d\n",x+y);}return 0;}
0 0
- 简单题:Your task is to Calculate a + b.
- Your task is to Calculate a + b.
- Problem Description Your task is to calculate the sum of some integers. Input Input contains an
- In this problem, your task is to calculate SUM(n) = 1 + 2 + 3 + ... + n.
- I have a very simple problem for you. Given two integers A and B, your job is to calculate the Sum o
- Calculate A + B.
- HDOJ-1089 Calculate a + b
- How to Calculate Your Shared Pool Size
- What is the best way to calculate a checksum for a file that is on my machine?
- Your Progress As A Programmer Is All Up To You
- Today is a perfect day to start living your dream.
- S1001 无休止的 Calculate A+B
- How to Calculate Your Shared Pool Size [ID 1012046.6]
- How to Calculate Your Shared Pool Size (文档 ID 1012046.6)
- springBoot启动错误 Your ApplicationContext is unlikely to start due to a @ComponentScan of the default
- Your ApplicationContext is unlikely to start due to a @ComponentScan of the default package.
- Your ApplicationContext is unlikely to start due to a @ComponentScan of the default package.
- Your ApplicationContext is unlikely to start due to a @ComponentScan of the default package
- getActionBar().setDisplayHomeAsUpEnabled(true)报错空指针异常
- ASP.Net程序插入错误: 列名或所提供值的数目与表定义不匹配
- Quated-Printable解码及出错解决方式
- opencv清晰度,色偏等评价函数
- Spring Boot实战之全局异常捕获 实现参数异常检查返回统一错误信息
- 简单题:Your task is to Calculate a + b.
- LeetCode 2. Add Two Numbers
- Animation-Layer
- const 常量指针
- MySQL中的数据类型
- 一文看尽中国互动直播行业——低俗无聊?那是现状,不是未来
- Eclipse开发C/C++之使用技巧小结,写给新手
- 推荐算法预览
- msm8610 lcd driver code analysis