import java.util.Scanner; public class Score { public static void main(String[] args) { System.out.println("请输入评委个数"); Scanner sc = new Scanner(System.in); int num = sc.nextInt(); int []arr = new int[num]; cin(arr); System.out.println("去掉一个最低分"+Minscore(arr)); System.out.println("去掉一个对高分"+Maxscore(arr)); int score = (Sumarr(arr) - Minscore(arr) - Maxscore(arr)) / (num - 2); System.out.println("最终得分:"+ score); } public static void cin(int arr[]){ Scanner sd = new Scanner(System.in); for(int i = 0;i < arr.length;i++){ System.out.print("请输入第"+(i+1)+"个评委的分数:"); arr[i] = sd.nextInt(); } } public static int Minscore(int[] arr){ int mina = arr[0]; for(int i =1;i<arr.length;i++){ if(arr[i]<mina) mina = arr[i]; } return mina; } public static int Maxscore(int[] arr){ int maxa = arr[0]; for(int i =1;i<arr.length;i++){ if(arr[i]>maxa) maxa = arr[i]; } return maxa; } public static int Sumarr(int[] arr){ int suma = 0; for(int i = 0;i<arr.length;i++){ suma += arr[i]; } return suma; } }