笔试编程题输入输出模板备忘
2017-03-27 10:35
141 查看
A+B Problem描述Given two integers a and b, calculate their sum a + b.输入The input contains several test cases. Each contains a line of two integers, a and b.输出For each test case output a+b on a seperate line.样例输入
1 2 3 4 5 6样例输出
3 7 11
语言 | 样例程序 |
---|---|
C | #include <stdio.h> int main(void) { int a, b; while(scanf("%d%d", &a, &b) != EOF) { printf("%d\n", a + b); } return 0; } |
C++ | #include <iostream> using namespace std; int main(void) { int a, b; while(cin >> a >> b) { cout << a + b << endl; } return 0; } |
Java | import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); while(in.hasNext()) { int a = in.nextInt(); int b = in.nextInt(); System.out.println(a + b); } } } |
C# | using System; public class AplusB { private static void Main() { string line; while((line = Console.ReadLine()) != null) { string[] tokens = line.Split(' '); Console.WriteLine(int.Parse(tokens[0]) + int.Parse(tokens[1])); } } } |
Python2 | while True: try: (x, y) = (int(x) for x in raw_input().split()) print x + y except EOFError: break |
相关文章推荐
- 笔试编程题输入输出模板备忘
- tornado开发输入输出,数据库操作,内置模板,综合示例
- CVTE c/c++软件类在线笔试 编程题
- 【Python】 网易笔试编程题(暗黑字符串)
- java 编程题输入输出处理
- 2018阿里巴巴秋招笔试编程题的自我探索
- 完美世界2017年实习生游戏c++开发工程师笔试编程题答案
- 搜狐2017 WEB前端开发 秋招笔试编程题
- 2016阿里巴巴笔试编程题用java和js 实现形如dssd-sdssd 转换成 DssdSdssd
- 文件操作与模板 编程题#2: 实数的输出格式(Coursera 程序设计与算法 专项课程3 C++程序设计 郭炜、刘家瑛;OpenJudge)
- 9月10日360笔试编程题
- 欢聚时代笔试题,滴滴出行编程题
- 【2018校招美团内推笔试编程题1】K的倍数
- 京东2017实习生招聘在线笔试编程题题解
- 滴滴出行2017秋招工程岗笔试题(0918)编程题
- 回《笔试常见的“阶乘”编程题,你写对了么?》
- 奇虎360_2017校园招聘笔试编程题第二题
- 笔试面试题解备忘1:字符串转换成整数
- (网易2018校招笔试)[编程题] 游历魔法王国
- 宜信笔试题--编程题