Home > Back-end >  New people for help, why not run?
New people for help, why not run?

Time:09-22

import java.util.Scanner;
Public class evaluation {

Public static void main (String [] args) {
Int [] arr=new int [5].
//TODO Auto - generated method stub
Scanner in=new Scanner (System. In);
Arr. [0]=in nextInt ();
Arr. [1]=in nextInt ();
Arr. [2]=in nextInt ();
Arr. [3]=in nextInt ();
Arr. [4]=in nextInt ();
Int I=0, j=0, k=0;
for(i=0; iIf (arr [I] K=arr [I];
Arr=arr [I] [I + 1);
Arr [I + 1]=k;
}
System. The out. Print (" maximum value for "+ arr [0] +" minimum value is: "+ arr [4]);




}

}

CodePudding user response:

1, if not in the loop, instant didn't do inside the loop border restrictions, arr leads to subscript bounds, [I + 1]
2, code logic single cycle is not in the out. Print (" maximum value for "+ arr [0] +" minimum value is: "+ arr [4]) in the correct values,
3, bubble sort
 
Public static void main (String [] args) {
Int [] arr=new int [5].
//TODO Auto - generated method stub
Scanner in=new Scanner(System.in);
Arr. [0]=in nextInt ();
Arr. [1]=in nextInt ();
Arr. [2]=in nextInt ();
Arr. [3]=in nextInt ();
Arr. [4]=in nextInt ();
Int I=0, j=0, k=0;
for (i=0; i For (j=I + 1; J & lt; Arr. Length; J++) {
If (arr [I] K=arr [I];
Arr=arr [I] [j];
Arr [j]=k;
}
}
}
System. The out. Print (" maximum value for "+ arr [0] +" minimum value is: "+ arr [4]);
}

CodePudding user response:

Arr [I + 1) crossing the line, for inside conditions should i CodePudding user response:

Still can not run after 1, compiler hint is: class evaluation is public, should be called evaluated. Java file statement, what is the meaning of this?

CodePudding user response:

When is your I=4, I + 1 is equal to 5, that's a good deal

CodePudding user response:

When is your I=4, I + 1 is equal to 5, that's a good deal

CodePudding user response:

reference weixin_47331441 reply: 3/f
1 still cannot run, after the compiler hint is: class evaluation is public, should be called evaluated. Java file statement, what is the meaning of this?


The Java class name and file name, the name of the class had better use English, Chinese have coding problem,
  • Related