ACM ICPC如何使用PC ^ 2?

时间:2014-11-01 04:26:50

标签: java io file

昨天我们在PC上进行了练习^ 2它是比赛的官方判断软件,但我遇到了问题,我的问题代码是正确的,答案是正确的,但是当我发送给软件时它回答我“运行时错误”。

我认为我在输入文件中的问题是他们想要输入文件和搁浅输出的输入,这是我第一次处理文件所以我去了默认包然后新的>其他>空>然后我用输入填充文件,然后我写了这个代码,它在我的电脑上100%工作然后我通过pc提交它^ 2我发送.java文件只是他们说,但它告诉我运行时错误。

以下是问题problem B,但他们希望从文件输入任何有该软件使用经验的人都会帮助我。

import java.io.File;
import java.util.Scanner;

public class omar {

    public static void main(String[] args) throws Exception {
        Scanner n = new Scanner(new File("C:\\Users\\omar\\Documents\\NetBeansProjects\\omar\\src\\omar.in"));
        int t = n.nextInt();
        int x;
        char o;
        int y;
        int z;
        int res;
        String[] c = new String[t];
        for (int i = 0; i < t; i++) {
            x = n.nextInt();
            o = n.next().charAt(0);
            y = n.nextInt();
            n.next();
            z = n.nextInt();
            if (o == '+') {
                res = x + y;
            } else {
                res = x - y;
            }
            if (res == z) {
                c[i] = "YES";
            } else {
                c[i] = "NO";
            }
        }
        int counter = 1;
        for (int j = 0; j < c.length; j++) {
            System.out.println("Case" + " " + counter + ":" + " " + c[j]);
            counter++;
        }
    }
}

1 个答案:

答案 0 :(得分:1)

Scanner n = new Scanner(new File("C:\\Users\\omar\\Documents\\NetBeansProjects\\omar\\src\\omar.in"));

这是文件在您的计算机中的位置。在Judge的计算机上运行程序时,这根本无济于事。你需要打开比赛说明所说的文件。