解题思路:
最后得分 = (总分 - 最高分 - 最低分) / (评分人数 - 2);
注意事项:
参考代码:import java.util.Scanner;
public class C1265 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (sc.hasNext()) {
int n = sc.nextInt();
double min = Double.MAX_VALUE, max = 0, sum = 0, score = 0;
for(int i = 0; i < n; i++){
score = sc.nextDouble();
if(score < min)
min = score;
if(score > max)
max = score;
sum += score;
}
System.out.printf("%.2f\n", (sum - min - max)/(n-2));
}
sc.close();
}
}
本文介绍了一种去除最高分和最低分后的平均分计算方法,并提供了完整的Java代码实现。该算法适用于比赛评分等场景,通过排除异常值来获得更公正的评分结果。
1万+

被折叠的 条评论
为什么被折叠?



