import java.util.Scanner;
public class code1 {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
System.out.println("请输入有多少评委");
int number=sc.nextInt();
System.out.println(getscore(number));
}
public static double getscore(int number){
int[] scores=new int [number];
Scanner sc= new Scanner(System.in);
for (int i = 0; i < scores.length; i++) {
System.out.println("请输入第"+(i+1)+"个分数");
scores[i]=sc.nextInt();
}
int sum=0;
int max=scores[0];
int min=scores[0];
for (int i = 0; i < scores.length; i++) {
int score=scores[i];
sum+=score;
if(score>max){
max=score;
}
if(min<score){
min=score;
}
}
return 1.0*(sum-max-min)/(number-2);
}
}
Java去除最高分最低分求其平均数
于 2023-09-19 21:23:57 首次发布