总时间限制: 
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++:

  1. #include <iostream>
  2. using namespace std;
  3. int  main()
  4. {
  5. int a,b;
  6. cin >> a >> b;
  7. cout << a+b << endl;
  8. return 0;
  9. }

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:

  1. #include <stdio.h>
  2. int main()
  3. {
  4. int a,b;
  5. scanf("%d %d",&a, &b);
  6. printf("%d\n",a+b);
  7. return 0;
  8. }

Here is a sample solution for problem 1000 using PASCAL:

  1. program p1000(Input,Output);
  2. var
  3. a,b:Integer;
  4. begin
  5. Readln(a,b);
  6. Writeln(a+b);
  7. end.

Here is a sample solution for problem 1000 using JAVA:

Now java compiler is jdk 1.5, next is program for 1000

  1. import java.io.*;
  2. import java.util.*;
  3. public class Main
  4. {
  5. public static void main(String args[]) throws Exception
  6. {
  7. Scanner cin=new Scanner(System.in);
  8. int a=cin.nextInt(),b=cin.nextInt();
  9. System.out.println(a+b);
  10. }
  11. }

Old program for jdk 1.4

  1. import java.io.*;
  2. import java.util.*;
  3. public class Main
  4. {
  5. public static void main (String args[]) throws Exception
  6. {
  7. BufferedReader stdin =
  8. new BufferedReader(
  9. new InputStreamReader(System.in));
  10. String line = stdin.readLine();
  11. StringTokenizer st = new StringTokenizer(line);
  12. int a = Integer.parseInt(st.nextToken());
  13. int b = Integer.parseInt(st.nextToken());
  14. System.out.println(a+b);
  15. }
  16. }

源代码:



  1. <pre name="code" class="cpp">int main(void)
  2. {
  3. int a, b;
  4. scanf("%d%d", &a, &b);
  5. printf("%d", a+b);
  6. return 0;
  7. }

1:A+B Problem的更多相关文章

  1. 1199 Problem B: 大小关系

    求有限集传递闭包的 Floyd Warshall 算法(矩阵实现) 其实就三重循环.zzuoj 1199 题 链接 http://acm.zzu.edu.cn:8000/problem.php?id= ...

  2. 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 ...

  3. C - NP-Hard Problem(二分图判定-染色法)

    C - NP-Hard Problem Crawling in process... Crawling failed Time Limit:2000MS     Memory Limit:262144 ...

  4. Time Consume Problem

    I joined the NodeJS online Course three weeks ago, but now I'm late about 2 weeks. I pay the codesch ...

  5. Programming Contest Problem Types

        Programming Contest Problem Types Hal Burch conducted an analysis over spring break of 1999 and ...

  6. hdu1032 Train Problem II (卡特兰数)

    题意: 给你一个数n,表示有n辆火车,编号从1到n,入站,问你有多少种出站的可能.    (题于文末) 知识点: ps:百度百科的卡特兰数讲的不错,注意看其参考的博客. 卡特兰数(Catalan):前 ...

  7. BZOJ2301: [HAOI2011]Problem b[莫比乌斯反演 容斥原理]【学习笔记】

    2301: [HAOI2011]Problem b Time Limit: 50 Sec  Memory Limit: 256 MBSubmit: 4032  Solved: 1817[Submit] ...

  8. [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 ...

  9. [LeetCode] The Skyline Problem 天际线问题

    A city's skyline is the outer contour of the silhouette formed by all the buildings in that city whe ...

  10. PHP curl报错“Problem (2) in the Chunked-Encoded data”解决方案

    $s = curl_init(); curl_setopt($s, CURLOPT_POST, true); curl_setopt($s, CURLOPT_POSTFIELDS, $queryStr ...

随机推荐

  1. springboot 连接池wait_timeout超时设置

    使用springboot 线程池连接MySQL时,mysql数据库wait_timeout 为8个小时,所以程序第二天发现报错,在url配置了 autoReconnect=true 也不行,查询配置以 ...

  2. join

    一句话 join(param) 是把  array 连城一个字符串,中间用 param隔开

  3. Android自定义图形shape

    在Android开发过程中,经常需要改变控件的默认样式, 那么通常会使用多个图片来解决.不过这种方式可能需要多个图片,比如一个按钮,需要点击时的式样图片,默认的式样图片. 这样就容易使apk变大.另一 ...

  4. Java集合中Comparator和Comparable接口的使用

    在Java集合中,如果要比较引用类型泛型的List,我们使用Comparator和Comparable两个接口. Comparable接口 -- 默认比较规则,可比较的 实现该接口表示:这个类的实例可 ...

  5. Mac下安装MySQL

    2015-07-13 15:10:32 Mac下用homebrew安装软件还是很方便的 brew install mysql 等待一会儿安装完毕后到安装目录: /usr/local/Cellar/my ...

  6. 8. javacript高级程序设计-BOM

    1. BOM 1.1 window BOM的核心对象是window,它表示浏览器的一个实例.在浏览器中,window对象有双重身份, 1.1.1 全局作用域 由于window对象同时扮演着ECMASc ...

  7. SQL Server 2008登录错误:无法连接到(local)的解决方法

    1.服务器类型我们选择了“数据库引擎”时,查找里面的可登录用户名是没有的,下边的服务器名称只显示为“(local)”,连“Windows 身份验证”都无法登录. 如果朋友们和我出错的问题是一样请看下面 ...

  8. JS 循环练习

    规律   大范围套小范围   循环   分支语句   switch case 嵌套  死循环 while(true)  打破循环   break    continue    while(true) ...

  9. windows端口备忘

    FTP 端口号21 SSH 端口号22 Telnet 端口号23

  10. 分布式缓存系统Memcached简介与实践

    缘起: 在数据驱动的web开发中,经常要重复从数据库中取出相同的数据,这种重复极大的增加了数据库负载.缓存是解决这个问题的好办法.但是ASP.NET中的虽然已经可以实现对页面局部进行缓存,但还是不够灵 ...