[解题报告]ZOJ 1001

来源:互联网 发布:windows.h和cwindows.h 编辑:程序博客网 时间:2024/05/16 06:54

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 IDSubmit TimeJudge StatusProblem IDLanguageRun Time(ms)Run Memory(KB)User Name16470682008-09-19 10:52:03Accepted 1001FPC0396幻の上帝16470662008-09-19 10:51:24Accepted 1001C0240幻の上帝16470652008-09-19 10:50:50Accepted 1001C++0264幻の上帝16470632008-09-19 10:49:21Accepted 1001C0240幻の上帝