hzxie / voj

A cross-platform online judge system based on Spring MVC framework and ActiveMQ.
https://verwandlung.org
GNU General Public License v3.0
569 stars 121 forks source link

java代码编译错误 #50

Closed haitaoya closed 5 years ago

haitaoya commented 5 years ago

提交页面voj提交页面详情 题目 P1000 A+B Problem 代码

import java.util.Scanner;

public class Main {
    int add(int a,int b) {
        return a+b;
    }
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int a = in.nextInt();
        int b = in.nextInt();
        Main main=new Main();
        System.out.println(main.add(a, b));
    }
}

编译错误

Compile Error.

/tmp/voj-1343/NuWpqoaGFISb.java:11: error: cannot find symbol

    Main main=new Main();

    ^
symbol: class Main

location: class NuWpqoaGFISb

/tmp/voj-1343/NuWpqoaGFISb.java:11: error: cannot find symbol

    Main main=new Main();

                  ^
symbol: class Main

location: class NuWpqoaGFISb

2 errors

Compile Error, Time = 0 ms, Memory = 0 KB, Score = 0.

好像无法使用 Main main=new Main();

haitaoya commented 5 years ago

image 是否是这里的原因呢

haitaoya commented 5 years ago

voj 提交详情 这里 直接提交 System.out.println(); 就AC了...

hzxie commented 5 years ago

是的。 编译的时候会更换类的名称。这是为了防止你们在程序里递归调用程序攻击评测机。

haitaoya commented 5 years ago

@hzxie 嗯,还有P1000 A+B Problem这道题目,直接提交System.out.println(); 就能AC

hzxie commented 5 years ago

What?这??? 晚些时候我检查一下评测机的代码吧。

haitaoya commented 5 years ago

嗯嗯,我大概找到了 问题位置。尝试修改一下.... image

hzxie commented 5 years ago

这个逻辑的确有问题。感谢指正。

hzxie commented 5 years ago

The problem has been solved. See: