java “java结果”是什么意思?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3170762/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 00:40:17  来源:igfitidea点击:

What does "java result" means?

java

提问by Kamran

after execution of my program written in java I see this output:

执行我用 java 编写的程序后,我看到这个输出:

java result: 2147483647

java 结果:2147483647

What does this number means anyway? This is the code. Tt should actually run random test cases on an ACM problem solution! no way to stop normally! and when I stop it manually I see this output:

这个数字到底是什么意思?这是代码。实际上应该在 ACM 问题解决方案上运行随机测试用例!没办法正常停止!当我手动停止它时,我看到了这个输出:

Java Result: 2147483647
BUILD SUCCESSFUL (total time: 8 minutes 49 seconds)

Java 结果:2147483647
BUILD SUCCESSFUL(总时间:8 分 49 秒)

I just want to know what does that number means?

我只想知道这个数字是什么意思?

package acm;
import java.util.Random;
import java.util.Scanner;
import java.util.Vector;
public class mamoth {
static Scanner input = new Scanner(System.in);
public static String planets;
public static int H;
public static int A;
public static Random random = new Random();

public static void main(String []args)
{
    while(!(planets = /*input.nextLine()*/Integer.toString(random.nextInt(10)+1) + " " + Integer.toString(random.nextInt(10)+1)).equals("0 0")){
        System.out.println(planets);
    //while(!(planets = input.nextLine()).equals("0 0")){
        int index;
        index = planets.indexOf(' ');
        H = Integer.valueOf(planets.substring(0, index));
        A = Integer.valueOf(planets.substring(index+1));
        Vector<Integer> humanPlanets = new Vector<Integer>();

        String temp = "1 0";
        for(int i=0;i<H-1;i++){
            temp += " 1 0";
        }

        planets = /*input.nextLine()*/temp;
        System.out.println(planets);
        //planets = input.nextLine();
       int index1 = 0;
       int index2;
       while((index2 = planets.indexOf(' ',index1))!=-1){
           humanPlanets.addElement(Integer.valueOf(planets.substring(index1, index2)));
           index1= index2+1;
       }
       humanPlanets.addElement(Integer.valueOf(planets.substring(index1)));

       Vector<Integer> aliasPlanets = new Vector<Integer>();

       temp = "0 0";
        for(int i=0;i<A-1;i++){
            temp += " 0 0";
        }

       planets = /*input.nextLine()*/temp;
        System.out.println(planets);
       //planets = input.nextLine();
       index1 = 0;
       while((index2 = planets.indexOf(' ',index1))!=-1){
           aliasPlanets.addElement(Integer.valueOf(planets.substring(index1, index2)));
           index1= index2+1;
       }
       aliasPlanets.addElement(Integer.valueOf(planets.substring(index1)));

       int[][] distance = new int[H][A];
       for(int i=0;i<H;i++){

           temp = Integer.toString(random.nextInt(100)+1);
        for(int b=0;b<A-1;b++){
            temp += " " + Integer.toString(random.nextInt(100)+1);
        }

           planets = /*input.nextLine()*//*Integer.toString(random.nextInt(100)+1) + " " + Integer.toString(random.nextInt(100)+1) + " " + Integer.toString(random.nextInt(100)+1)*/temp;

           //planets = input.nextLine();
           index1 = 0;
           int j =0;
           while((index2 = planets.indexOf(' ',index1))!=-1){
               distance[i][j] = Integer.valueOf(planets.substring(index1, index2));
               index1= index2+1;
               j++;
           }
           distance[i][j] = Integer.valueOf(planets.substring(index1));

       }
        if(H>=A){

       int[][] minimumYearsToDefeat = new int[H][A];
       for(int i=0;i<H;i++){
           for(int j=0;j<A;j++){
               double x,y,z;
               y = aliasPlanets.elementAt(j*2) + humanPlanets.elementAt(i*2+1)*distance[i][j]-humanPlanets.elementAt(i*2);
               z = humanPlanets.elementAt(i*2+1) - aliasPlanets.elementAt(j*2+1);
               if(z==0){
                   if(y<=0)
                       x = distance[i][j];
                   else
                       x = Integer.MAX_VALUE;
               }
               else{
               x = y/z;
               }
               if(x==0){
                   x=1;
               }
               else if(x<0){
                   x= Integer.MAX_VALUE;
               }
               minimumYearsToDefeat[i][j] = (int)Math.ceil(x);
           }
       }

       for(int i=0;i<H;i++){
           for(int j=0;j<A;j++)
               System.out.print(minimumYearsToDefeat[i][j]+" ");
           System.out.println();
       }

       int[] mins = new int[A];//meqdar dehi ba big integer
       for(int i=0;i<A;i++){
           mins[i] = Integer.MAX_VALUE;
       }
       int[] minsWith = new int[A];//meqdar dehi ba -1
       for(int i=0;i<A;i++){
           minsWith[i] = -1;
       }

       for(int i=0;i<A;i++){
           for(int j=0;j<H;j++){
               if(minimumYearsToDefeat[j][i]<mins[i]){
                   mins[i] = minimumYearsToDefeat[j][i];
                   minsWith[i] = j;
               }
           }


           for(int p=0;p<A;p++){
               if(minsWith[i]==minsWith[p]&&p!=i&&mins[i]!=Integer.MAX_VALUE){
                   correctingConflict(minimumYearsToDefeat, mins, minsWith, i, p, new Vector<Integer>());
               }
           }


       }
       int result = 0;
       for(int i=0;i<A;i++){
           if (mins[i]>result)
               result = mins[i];

       }
       if(result==Integer.MAX_VALUE){
           System.out.println("IMPOSSIBLE");
       }
       else{
           System.out.println(result);
       }
    }
        else{
            System.out.println("IMPOSSIBLE");
        }
    }
}

public static void correctingConflict(int[][] W, int[] mins, int[] minsWith, int i, int p, Vector<Integer> vector){
    /*for(int v=0;v<A;v++){
    System.out.print(minsWith[v]+" ");
    }
    System.out.println();
    for(int v=0;v<vector.size();v++){
    System.out.print(vector.elementAt(v)+" ");
    }
    System.out.println();*/
    int nextMin1 = Integer.MAX_VALUE;
    int nextMin2 = Integer.MAX_VALUE;
    int nextMinWith1 = minsWith[i];
    int nextMinWith2 = minsWith[p];

    for(int q=0;q<H;q++){
        if(W[q][i]<nextMin1 && W[q][i]>=mins[i] && q!=minsWith[i] && !vector.contains(q)){
            nextMin1 = W[q][i];
            nextMinWith1 = q;
        }

    }
    for(int q=0;q<H;q++){
        if(W[q][p]<nextMin2 && W[q][p]>=mins[p] && q!=minsWith[p] && !vector.contains(q)){
            nextMin2 = W[q][p];
            nextMinWith2 = q;
        }
    }

    if(nextMin1<=nextMin2){
        if (nextMin1==mins[i]) {
            vector.addElement(minsWith[p]);
        } else {
            vector.removeAllElements();
        }
        mins[i] = nextMin1;
        minsWith[i] = nextMinWith1;

        //conflict checking
        for(int s=0;s<A;s++){
               if(minsWith[i]==minsWith[s]&&s!=i&&mins[i]!=Integer.MAX_VALUE){
                   correctingConflict(W, mins, minsWith, i, s, vector);
                   return;
               }
        }

    }
    else if(nextMin2<nextMin1){
        if (nextMin2==mins[p]) {
            vector.removeAllElements();
            vector.addElement(minsWith[p]);
        } else {
            vector.removeAllElements();
        }
        mins[p] = nextMin2;
        minsWith[p] = nextMinWith2;

        //conflict checking
        for(int s=0;s<A;s++){
               if(minsWith[p]==minsWith[s]&&s!=p&&mins[p]!=Integer.MAX_VALUE){
                   correctingConflict(W, mins, minsWith, p, s, vector);
                   return;
               }
        }
    }




}

}

回答by Jon Skeet

Well, you haven't shown how you're executing your program or what your program does. I would guessit could be the exit code of the process, although usually if there aren't any errors, the exit code is 0.

好吧,您还没有展示您如何执行您的程序或您的程序做了什么。我这可能是进程的退出代码,尽管通常如果没有任何错误,退出代码为 0。

If you want a better answer, please provide more information in the question.

如果您想要更好的答案,请在问题中提供更多信息。

回答by sarnold

You assign Integer.MAX_VALUEin five different places in your code; one of the locations is elements in the minsarray.

Integer.MAX_VALUE在代码中的五个不同位置分配;位置之一是mins数组中的元素。

This code near the end of your main()method can print out values from the minsarray:

靠近main()方法末尾的这段代码可以打印出mins数组中的值:

   int result = 0;
   for(int i=0;i<A;i++){
       if (mins[i]>result)
           result = mins[i];

   }
   if(result==Integer.MAX_VALUE){
       System.out.println("IMPOSSIBLE");
   }
   else{
       System.out.println(result);
   }
}
    else{
        System.out.println("IMPOSSIBLE");
   }
   int result = 0;
   for(int i=0;i<A;i++){
       if (mins[i]>result)
           result = mins[i];

   }
   if(result==Integer.MAX_VALUE){
       System.out.println("IMPOSSIBLE");
   }
   else{
       System.out.println(result);
   }
}
    else{
        System.out.println("IMPOSSIBLE");
   }

Here's a small test program to find out what Integer.MAX_VALUEactually is:

这是一个小型测试程序,用于了解Integer.MAX_VALUE实际情况:

$ cat test.java ; javac test.java ; java sars
class sars {
    public static void main(String args[]) {
            System.out.println("Integer.MAX_VALUE: " + Integer.MAX_VALUE);
    }
}
Integer.MAX_VALUE: 2147483647

I was wrong in my earlier comment about a -1 leaking through somewhere -- you've embedded the funny value fivetimes into your code. :) I don't know which one is leaking out, or if your algorithm is actually working exactly as it should. Good luck hunting that down :) but at least with your full code posted, someone may help you find what we're both missing.

我之前关于 -1 泄漏到某处的评论是错误的——您已经将有趣的值五次嵌入到您的代码中。:) 我不知道是哪一个泄露了,或者你的算法是否真的按照它应该的方式工作。祝你好运:) 但至少在你发布了完整的代码后,有人可能会帮助你找到我们都缺少的东西。

回答by Mike Baranczak

If you have a default NetBeans project, and you're launching it from NetBeans, then it's being launched by Ant, using the generated build script that's inside your project directory. To narrow down the problem, try launching the program yourself from the command line:

如果您有一个默认的 NetBeans 项目,并且您是从 NetBeans 启动它,那么它是由 Ant 启动的,使用的是项目目录中生成的构建脚本。要缩小问题的范围,请尝试从命令行自己启动程序:

java acm.mamoth

回答by Mohammad Esfandiari

It is because of the date and time. It means that you have some files that edited in a date or time after your current date and time. set your date and time to a valid date and then run your program.

这是因为日期和时间。这意味着您有一些文件在当前日期和时间之后的日期或时间进行了编辑。将您的日期和时间设置为有效日期,然后运行您的程序。

回答by Carlos Felipe Silva Espinoza

It's the exit code from the (JVM) process. Specifically, it's the one you'll get when you kill it. Unknown Java Result Message

这是(JVM)进程的退出代码。具体来说,它是你杀死它时会得到的。 未知 Java 结果消息

回答by Thorbj?rn Ravn Andersen

Let the Java code end explicitly with an System.exit(0)

让 Java 代码以 System.exit(0) 显式结束