package com.imooc;
import java.util.Arrays;
import java.util.Scanner;
public class HelloWorld {
public static void main(String[] args){
int[] score = new int[6];
HelloWorld hello = new HelloWorld();
Scanner input = new Scanner(System.in);
for(int i=0;i<6;i++){
System.out.print("请输入第"+(i+1)+"个人的成绩:");
score[i] = input.nextInt();
}
String result = hello.getTop3(score);
System.out.println("前三名的成绩为:"+result);
}
/**
* 求所有考试成绩中的前三名
* @return 前三名的成绩
*/
public String getTop3(int[] score){
int[] top3 = new int[3];
int j = 0;
Arrays.sort(score);
for(int i=score.length-1;i>score.length-4;i--){
if(score[i] >100 || score[i] < 0) continue;
top3[j++] = score[i];
}
return Arrays.toString(top3);
}
}