牛客网在线判题系统使用帮助

作者:管理员
链接:https://www.nowcoder.com/discuss/276
来源:牛客网

1 判题系统的编译器信息

C/C++:clang++ 3.9 -std=c++14 -O -Wsign-compare -Wc++11-extensions

JAVA:javac 1.8 -encoding=utf-8

Python: python 2.7.3

Python3: python 3.2.3

C#: mcs 4.0.1

Go: go 1.8.3

2. 判题系统的输入输出

2.1 对于<剑指Offer>这种有函数定义的题目,你只要完成函数,返回相关的值就可以,不需要处理任何输入输出,不要在函数里输出任何东西。

2.2 对于传统ACM的OJ模式题目,你的程序需要stdin(标准输入)读取输入,然后stdout(标准输出)来打印结果,举个例子,你可以使用c语言的scanf或者c++的cin来读取输入,然后使用c语言的printf或者c++的cout来输出结果。代码禁止读取和写入任何文件,否则判题系统将会返回运行错误。OJ一次处理多个case,所以代码需要循环处理,一般通过while循环来出来多个case。以下是A+B题目的样例代码,http://www.nowcoder.com/questionTerminal/dae9959d6df7466d9a1f6d70d6a11417

C 64位输出请用printf("%lld")

#include

int main() {

int a,b;

while``(scanf(``"%d %d"``,&a, &b) != EOF)``//注意while处理多个case

printf(``"%d\n"``,a+b);

return 0``;

}

|

C++ 64位输出请用printf("%lld")

#include

using namespace std;

int main() {

int a,b;

while``(cin >> a >> b)``//注意while处理多个case

cout << a+b << endl;

}

JAVA,注意类名必须为Main, 不要有任何package xxx信息

注意hasNext和hasNextLine的区别,详细见

import java.util.Scanner;

public class Main {

public static void main(String[] args) {

Scanner in = new Scanner(System.in);

while (in.hasNextInt()) {``//注意while处理多个case int a = in.nextInt();

int b = in.nextInt();

System.out.println(a + b);

}

}

}

C#

public class Program {

public static void Main() {

string line;

while ((line = System.Console.ReadLine ()) != null``) {``//注意while处理多个case

string[] tokens = line.Split();

System.Console.WriteLine(``int``.Parse(tokens[``0``]) + int``.Parse(tokens[``1``]));

}

}

}

Python

import sys

try``:

while True:

line = sys.stdin.readline().strip()

if line == ''``:

break

lines = line.split()

print int``(lines[``0``]) + int``(lines[``1``])

except:

pass

Python3

import sys

for line in sys.stdin:

a = line.split()

print``(``int``(a[``0``]) + int``(a[``1``]))

JavaScript(V8)

while``(line=readline()){

var lines = line.split(``' '``);

var a = parseInt(lines[0]);

var b = parseInt(lines[1]);

print(a+b);

}

JavaScript(Node)

var readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
rl.on('line', function(line){
var tokens = line.split(' ');
console.log(parseInt(tokens[0]) + parseInt(tokens[1]));
});

Php

while``(``fscanf``(STDIN, "%d %d"``, $a``, $b``) == 2)

echo (``$a + $b``).``"\n"``;

Go

package main
import (
"fmt"
)
func main() {
a:=0
b:=0
for {
n, _ := fmt.Scan(&a,&b)
if n == 0 {
break
} else {
fmt.Printf("%d\n",a+b)
}
}
}

R语言

lines=readLines(``"stdin"``)

for``(l in lines){

if``(l == ""``){

break``;

}

ll = strsplit(l, " "``)[[1]]

a=ll[1];

b=ll[2];

cat(as.numeric(a)+as.numeric(b));

cat(``'\n'``);

}

3. 判题系统状态

等待评测: 评测系统还没有评测到这个提交,请稍候
正在评测: 评测系统正在评测,稍候会有结果
编译错误:您提交的代码无法完成编译,点击“编译错误”可以看到编译器输出的错误信息
答案正确: 恭喜!您通过了这道题
运行错误: 您提交的程序在运行时发生错误,可能是空指针

部分正确: 您的代码只通过了部分测试点,继续努力!
格式错误: 您的程序输出的格式不符合要求(比如空格和换行与要求不一致)
答案错误: 您的程序未能对评测系统的数据返回正确的结果
运行超时: 您的程序未能在规定时间内运行结束
内存超限: 您的程序使用了超过限制的内存
异常退出: 您的程序运行时发生了错误
返回非零: 您的程序结束时返回值非 0,如果使用 C 或 C++ 语言要保证 int main 函数最终 return 0
浮点错误: 您的程序运行时发生浮点错误,比如遇到了除以 0 的情况
段错误 : 您的程序发生段错误,可能是数组越界,堆栈溢出(比如,递归调用层数太多)等情况引起
多种错误: 您的程序对不同的测试点出现不同的错误
内部错误: 请仔细检查你的代码是否有未考虑到的异常情况,例如非法调用、代码不符合规范等。

4. 开始练习吧

http://www.nowcoder.com/books/coding-interviews

http://www.nowcoder.com/questionCenter?orderByHotValue=0&questionTypes=000100

5. 有任何问题加QQ群 244930442

你可能感兴趣的:(牛客网在线判题系统使用帮助)