首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在USACO中,这个编译器不断出现

在USACO中,这个编译器不断出现
EN

Stack Overflow用户
提问于 2016-10-03 09:13:17
回答 1查看 108关注 0票数 0
代码语言:javascript
复制
ride.java:8: class Ride is public, should be declared in a file named Ride.java
public class Ride {
       ^
1 error

这是我的代码

代码语言:javascript
复制
import java.util.*; 
import java.io.*;

public class Ride {

    static Scanner reader;
    static PrintWriter outFile;
    int num = 0;
    int total_c = 0;
    int total_g = 0;
    char [] comet = new char [6];
    char [] group = new char [6];

    public static void main (String [] args) throws Exception
    {
        reader = new Scanner(new File("ride.in"));
        outFile = new PrintWriter(new File("ride.out"));
        Ride r = new Ride();
        r.run();
    }

    public void run()
    {
        char in = '\0';
        int x = 0;
        while(reader.hasNext())
        {
            in = reader.next().charAt(0);
            if(x<6)
            {
                comet[x] = in;
            }
            else 
            {
                group[x-6] = in;
            }
            x++;
        } 

        for(int a = 0; a < 6; a++)
        {
            total_c *= (int)(comet[a]-64);
            total_g *= (int)(group[a]-64);
        }

        if(total_c%47 == total_g%47)
        {
            outFile.print("GO");
        }
        else
            outFile.print("STAY");
    }
}

我在Ride.java下有这个文件,但是USACO不能编译这个程序。

EN

回答 1

Stack Overflow用户

发布于 2016-10-03 10:12:16

如果您使用不同的文件名声明单个类,则可能会发生这种情况。作为一个简单的提醒:

Java文件名必须与公共类名相同。

@deco answer可以为您提供更多详细信息。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39823332

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档