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 ...
随机推荐
- ThinkPHP 知识点链接
1.Thinkphp3.2 行为扩展和插件(Hook) http://www.thinkphp.cn/topic/21323.html 2.ThinkPHP3.1.3的单字母函数汇总 ...
- 【GoLang】golang 交叉编译 实现&工具
apt-get install gcc-mingw-w64 env CGO_ENABLED= GOOS=windows GOARCH=amd64 CC=x86_64-w64-mingw32-gcc g ...
- ConsoleApplication 添加对于 System.ServiceModel.Web 引用失败(出现黄色感叹号)的解决办法
今天在写一个WebHttpBinding的demo,再创建一个Console应用程序后,发现无法添加System.ServiceModel.Web,如图
- poj 2378 (dijkstra)
http://poj.org/problem?id=2387 一个dijkstra的模板题 #include <stdio.h> #include <string.h> #de ...
- struts2配置文件的加载顺序以及 struts.xml package 的配置说明
查看StrutsPrepareAndExecuteFilter:(核心过滤器)两个功能 :预处理 和 执行 在预处理功能中 init 方法中会有加载配置文件的代码: dispatcher.init() ...
- Oracle java.sql.SQLException: 数字溢出
六月 30, 2016 5:47:47 下午 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinit ...
- windows.h和winsock2.h包含顺序问题(转)
windows.h和winsock2.h有类型重定义我是知道的,本来就一个库来说没问题,把winsock2放到windows.h前或先定义WIN32_LEAN_AND_MEAN都能解决问题但现的出了问 ...
- delphi cxgrid 使用方法
delphi cxgrid 使用方法1.绑定数据 方法 cxGrid1DBTableView1.DataController.DataSource:=DataSource12.去掉"Drag ...
- cannot use the same dataset for report.dataset and page.dataset
把page中的dataset中填的数据表删除.(改成not assigned)
- 25. javacript高级程序设计-新兴的API
1. 新兴的API requestAnimationFrame():是一个着眼于优化js动画的api,能够在动画运行期间发出信号.通过这种机制,浏览器就能够自动优化屏幕重绘操作 Page Visibi ...