50,673
社区成员
发帖
与我相关
我的任务
分享
public class Gymnastics {
public double computerAverage(double[] x) {
double all = x[0];
double max = x[0];
double min = x[0];
for (int i = 1; i < x.length; i++) {
if(max < x[i]) {
max = x[i];
}
if(min > x[i]) {
min = x[i];
}
all += x[i];
}
double endscore = (all - max - min) / (x.length - 2);
return endscore;
}
public static void main(String[] args) {
Gymnastics aa = new Gymnastics();
double[] dd = {4, 1, 2, 3};
System.out.println(aa.computerAverage(dd));
}
}