ZOJ Problem Set - 1001
A + B Problem
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1001。
[题目信息]
难度:Lv0(试机题)。
算法:数学->算术->加法。
[注释]
开始不知道AC数量按题数算,随便提交了好几遍,AC Ratio狂降。。。
Java是2008-11-26才可以用的,没试过。
注意C代码中EOF表示输入结束(在预处理中会被替换为-1)。
[代码]
引用:
ZOJ-FAQ页面-样例代码。
Here is a sample solution for problem 1001 using C++:
#include <iostream>
using namespace std;
int main()
{
int a,b;
while(cin >> a >> b)
cout << a+b << endl;
}
Here is a sample solution for problem 1001 using C:
#include <stdio.h>
int main()
{
int a,b;
while(scanf("%d %d",&a, &b) != EOF)
printf("%d/n",a+b);
}
Here is a sample solution for problem 1001 using PASCAL(FPC):
program p1001(Input,Output);
var
a,b:Integer;
begin
while not eof(Input) do
begin
Readln(a,b);
Writeln(a+b);
end;
end.
Here is a sample solution for problem 1001 using Java:
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
while (in.hasNextInt()) {
int a = in.nextInt();
int b = in.nextInt();
System.out.println(a + b);
}
}
}
[提交结果]
引用:
ZOJ搜索页面。
4 AC.
Run ID Submit Time Judge Status Problem ID Language Run Time(ms) Run Memory(KB) User Name 1647068 2008-09-19 10:52:03 Accepted 1001 FPC 0 396 幻の上帝 1647066 2008-09-19 10:51:24 Accepted 1001 C 0 240 幻の上帝 1647065 2008-09-19 10:50:50 Accepted 1001 C++ 0 264 幻の上帝 1647063 2008-09-19 10:49:21 Accepted 1001 C 0 240 幻の上帝