POJ 1000 A+B Problem

[*][size=large]题意翻译[/size]

输入两个整数a,b (0<=a,b<=10),计算a+b的值并输出。
其中还提到输出不能有多余的内容,即不能加多空格符号等内容,不然会报Wrong Answer
不能使用文件,不然会报"Runtime Error"或者"Wrong Answer"

[*][size=large]思路[/size]

这个poj用来解释如何编写代码以及提交的例子题目,我也是用此题建立我解题报告的模板。
思路很简单,就是加起来。

[*][size=large]总结[/size]

--使用Java是需要注意一下内容:

(1)只能使用一个java类,并且类名为Main,并且里面要有一个main方法作为类的开始位置。
(2)Java使用1.5

--使用GCC或者G++提交时要注意内容

(1)main方法一定要是int返回类型。

[*][size=large]代码[/size]

(1)C

[img]http://dl.iteye.com/upload/attachment/579008/c44739a7-cd2c-3561-ab36-2ef7a04c197a.png[/img]


#include "stdio.h"
int main()
{
int a,b;
scanf("%d%d",&a,&b);
printf("%d",a+b);
return 0;
}


(2)C++

[img]http://dl.iteye.com/upload/attachment/579010/a3afb7d1-4f71-3fc9-af31-4253288a7bf5.png[/img]


#include "iostream"
using namespace std;
int main()
{
int a,b;
cin>>a>>b;
cout<<a+b;
return 0;
}


(3)Java

[img]http://dl.iteye.com/upload/attachment/579012/2b0fd73a-0834-3bcf-8e65-a59b09dacfc0.png[/img]


import java.util.Scanner;
public class Main {
public static void main(String[] args) throws Exception{
Scanner scan = new Scanner(System.in);
int a = scan.nextInt();
int b = scan.nextInt();
System.out.println(a+b);
}
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值