1:A+B Problem
- 总时间限制:
- 1000ms
- 内存限制:
- 65536kB
- 描述
-
Calculate a + b
- 输入
- Two integer a,,b (0 ≤ a,b ≤ 10)
- 输出
- Output a + b
- 样例输入
-
1 2
- 样例输出
-
3
- 提示
- Q: Where are the input and the output?
A: Your program shall always read input from stdin (Standard Input) and write output to stdout (Standard Output). For example, you can use 'scanf' in C or 'cin' in C++ to read from stdin, and use 'printf' in C or 'cout' in C++ to write to stdout.
You shall not output any extra data to standard output other than that required by the problem, otherwise you will get a "Wrong Answer".
User programs are not allowed to open and read from/write to files. You will get a "Runtime Error" or a "Wrong Answer" if you try to do so.
Here is a sample solution for problem 1000 using C++/G++:
- #include <iostream>
- using namespace std;
- int main()
- {
- int a,b;
- cin >> a >> b;
- cout << a+b << endl;
- return 0;
- }
It's important that the return type of main() must be int when you use G++/GCC,or you may get compile error.
Here is a sample solution for problem 1000 using C/GCC:
- #include <stdio.h>
- int main()
- {
- int a,b;
- scanf("%d %d",&a, &b);
- printf("%d\n",a+b);
- return 0;
- }
Here is a sample solution for problem 1000 using PASCAL:
- program p1000(Input,Output);
- var
- a,b:Integer;
- begin
- Readln(a,b);
- Writeln(a+b);
- end.
Here is a sample solution for problem 1000 using JAVA:
Now java compiler is jdk 1.5, next is program for 1000
- import java.io.*;
- import java.util.*;
- public class Main
- {
- public static void main(String args[]) throws Exception
- {
- Scanner cin=new Scanner(System.in);
- int a=cin.nextInt(),b=cin.nextInt();
- System.out.println(a+b);
- }
- }
Old program for jdk 1.4
- import java.io.*;
- import java.util.*;
- public class Main
- {
- public static void main (String args[]) throws Exception
- {
- BufferedReader stdin =
- new BufferedReader(
- new InputStreamReader(System.in));
- String line = stdin.readLine();
- StringTokenizer st = new StringTokenizer(line);
- int a = Integer.parseInt(st.nextToken());
- int b = Integer.parseInt(st.nextToken());
- System.out.println(a+b);
- }
- }
-
源代码:
-
- <pre name="code" class="cpp">int main(void)
- {
- int a, b;
- scanf("%d%d", &a, &b);
- printf("%d", a+b);
- return 0;
- }
1:A+B Problem的更多相关文章
- 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 ...
- hdu1032 Train Problem II (卡特兰数)
题意: 给你一个数n,表示有n辆火车,编号从1到n,入站,问你有多少种出站的可能. (题于文末) 知识点: ps:百度百科的卡特兰数讲的不错,注意看其参考的博客. 卡特兰数(Catalan):前 ...
- BZOJ2301: [HAOI2011]Problem b[莫比乌斯反演 容斥原理]【学习笔记】
2301: [HAOI2011]Problem b Time Limit: 50 Sec Memory Limit: 256 MBSubmit: 4032 Solved: 1817[Submit] ...
- [LeetCode] Water and Jug Problem 水罐问题
You are given two jugs with capacities x and y litres. There is an infinite amount of water supply a ...
- [LeetCode] The Skyline Problem 天际线问题
A city's skyline is the outer contour of the silhouette formed by all the buildings in that city whe ...
- PHP curl报错“Problem (2) in the Chunked-Encoded data”解决方案
$s = curl_init(); curl_setopt($s, CURLOPT_POST, true); curl_setopt($s, CURLOPT_POSTFIELDS, $queryStr ...
随机推荐
- 【Java】嵌套For循环性能优化案例
参考资料:http://cgs1999.iteye.com/blog/1596671 1 案例描述 某日,在JavaEye上看到一道面试题,题目是这样的:请对以下的代码进行优化 for (int i ...
- Qt 信号槽如何传递参数(或带参数的信号槽)
信号槽如何传递参数(或带参数的信号槽) 利用Qt进行程序开发时,有时需要信号槽来完成参数传递.带参数的信号槽在使用时,有几点需要注意的地 ...
- frxReport 设计 (mtm)
► 设计 frxReport frxReport 窗体上放一个 [frxReport] 的控件 双击 [frxReport]控件 进入设置模式 frxReport1.ShowReport() 方 ...
- ABAP 单位转换函数
CALL FUNCTION 'UNIT_CONVERSION_SIMPLE' EXPORTING input = wa_all-btg ...
- 【Git】笔记5 分支管理2
来源:廖雪峰 通常,合并分支时,如果可能,Git会用Fast forward模式,但这种模式下,删除分支后,会丢掉分支信息. 如果要强制禁用Fast forward模式,Git就会在merge时生成一 ...
- C#实现把指定文件夹下的所有文件复制到指定路径下以及修改指定文件的后缀名
1.实现把指定文件夹下的所有文件复制到指定路径下 public static void copyFiles(string path) { DirectoryInfo dir = new Directo ...
- 建立controller
复制controller,重建controller 改: @Controller("[productController]") @RequestMapping("/[pr ...
- Swift - 懒加载(lazy initialization)
Swift中是存在和OC一样的懒加载机制的,在程序设计中,我们经常会使用 懒加载 ,顾名思义,就是用到的时候再开辟空间 懒加载 格式: lazy var 变量: 类型 = { 创建变量代码 }() 懒 ...
- jsp 过滤器 Filter 配置
.如果要映射过滤应用程序中所有资源: <filter> <filter-name>loggerfilter</filter-name> <filt ...
- Loadrunner11.0 录制手机App脚本的方法
使用Loadrunner录制手机终端App脚本 1. 说明 目前手机APP上的功能日益丰富,对手机应用功能的性能测试需求也越来越多.公司比较抠门没有花钱买Loadrunner,可怜我们工作中一直用的破 ...