public class Test01 {
public static void main(String[] args) {
int[] score = new int[]{89 , -23 , 64 , 91 , 119 , 52 , 73};
Test01 a = new Test01();
a.paiming(score);
}
//定义方法完成成绩排序并输出前三名的功能
void paiming(int[] b){
int ans=0;
Arrays.sort(b);
for(int i=6; i>=0; i--)
{
if(b[i]<=100)
{
ans++;
System.out.println(b[i]);
if(ans == 3) break;
}
}
System.out.println(Arrays.toString(b));
}
}
运行结果:
91
89
73
[-23, 52, 64, 73, 89, 91, 119]