原题链接
题目1 - ACM在线评测系统
http://acm.nyist.net/JudgeOnline/problem.php?pid=1
补充:
对于每次提交OJ都会有如下的几种返回结果:
Accepted:您的程序是正确的,恭喜!
Presentation Error:虽然您的程序貌似输出了正确的结果,但是这个结果的格式有点问题。请检查程序的输出是否多了或者少了空格(' ')、制表符('\t')或者换行符('\n')。
Wrong Answer:输出结果错,这个一般认为是算法有问题。点击链接可以查看具体的错误信息,可以得到相关提示。
Runtime Error:运行时错误,这个一般是程序在运行期间执行了非法的操作造成的。一般例如scanf函数的地址列表中缺少符号&、指针、数组下标越界、除数为0、堆栈溢出等。
Time Limit Exceeded:您的程序运行的时间已经超出了这个题目的时间限制。
Memory Limit Exceeded:您的程序运行的内存已经超出了这个题目的内存限制。
Output Limit Exceeded:您的程序输出内容太多,超过了这个题目的输出限制。
Compilation Error:您的程序语法有问题,编译器无法编译。具体的出错信息可以点击链接察看。
题目信息
A+B Problem
时间限制:3000 ms | 内存限制:65535 KB
难度:0
- 描述
- 此题为练手用题,请大家计算一下a+b的值
- 输入
- 输入两个数,a,b
- 输出
- 输出a+b的值
- 样例输入
-
2 3
- 样例输出
-
5
- 提示
- 例如:
C语言版:
#include<stdio.h>
int main()
{
int a,b;
scanf("%d%d",&a,&b);
printf("%d\n",a+b);
}
C++版:
#include<iostream>
using namespace std;
int main()
{
int a,b;
cin>>a>>b;
cout<<a+b<<endl;
}
Java版:
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);
}
}
Java 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);
}
}
请注意不要输出过多提示性语句(如:“please input two numbers”),不然会WrongAnswer的 - 我的代码:
-
1 #include <stdio.h> 2 int main(void) 3 { 4 int temp1, temp2; 5 scanf("%d %d", &temp1, &temp2); 6 printf("%d\n", temp1 + temp2); 7 return 0; 8 }
浙公网安备 33010602011771号