package com.Demo; import java.util.Scanner; //评委打分 //去除最高分和最低分求平均分 public class Test3 { public static void main(String[] args) { System.out.println("得分:"+lolo(6)); } public static double lolo(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)+"位评委打分"); int score=sc.nextInt(); scores[i]=score; } 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 (score<min){ min=score; } } return 1.0*(sum-min-max)/(number-2); } }
标签:int,打分,score,scores,评委,public From: https://www.cnblogs.com/Karl-hut/p/17437972.html