求大神解答8-1
错的:
public class HelloWorld {
public static void main(String[] args) {
int[] scores=new int[]{89,-23,64,91,119,52,73};
HelloWorld hello=new HelloWorld();
hello.rank(scores);}
public void rank(int[] arrays){
int[] score=new int[7];
for(int i=arrays.length-1;i>=0;i--){
if(arrays[i]<0&&arrays[i]>100){continue;}
else
score[i]=arrays[i];}
Arrays.sort(score);
System.out.println(score[6]+"\n"+score[5]+"\n"+score[4]);}}
对的:
import java.util.Arrays;
public class HelloWorld {
public static void main(String[] args) {
int[] scores=new int[]{89,-23,64,91,119,52,73};
HelloWorld hello=new HelloWorld();
hello.rank(scores);}
public void rank(int[] arrays){
int[] score=new int[7];
for(int i=arrays.length-1;i>=0;i--){
if(arrays[i]>=0&&arrays[i]<=100){ score[i]=arrays[i];}
else continue;}
Arrays.sort(score);
System.out.println(score[6]+"\n"+score[5]+"\n"+score[4]);}}