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; 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; iFor (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 iCodePudding user response:
When is your I=4, I + 1 is equal to 5, that's a good dealCodePudding user response:
When is your I=4, I + 1 is equal to 5, that's a good dealCodePudding user response: