RanEr不知道
2016-03-25 11:35
错的:
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]);}}
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[arrays.length-1]+"\n"+score[arrays.length-2]+"\n"+score[arrays.length-3]);} }
Java入门第一季(IDEA工具)升级版
1165172 学习 · 17581 问题
相似问题