[POJ 1000] A+B Problem 经典水题 C++解题报告 JAVA解题报告

 
 
A+B Problem
Time Limit: 1000MS   Memory Limit: 10000K
Total Submissions: 311263   Accepted: 171333

Description

Calculate a+b

Input

Two integer a,b (0<=a,b<=10)

Output

Output a+b
 

Sample Input

1 2

Sample Output

3

计算两个整数的和

解决思路

 

这是经典水题了,每个OJ必有的。
题目很简单,就是对输入的两个整数a和b,输出它们的和。

用C++的基本语法就能搞定。

C++:
 1 /*
 2 poj 1000
 3 version:1.0
 4 author:Knight
 5 Email:S.Knight.Work@gmail.com
  website:www.getyourwant.com
6 */ 7 8 #include<cstdio> 9 using namespace std; 10 11 int main() 12 { 13 int a,b; 14 scanf("%d%d", &a, &b); 15 printf("%d\n", a + b); 16 return 0; 17 }

 

 

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

 



 
posted @ 2014-01-18 12:46  玩物尚智  阅读(1097)  评论(0编辑  收藏  举报