//评委打分 去掉两个最高分 去掉两个最低分 求平均数 int []defen={78,79,80,83,89,99,90,76,88,98}; for(int a=0;a<defen.length;a++) { System.out.print(defen[a]+"\t"); } System.out.println();//第一步,初始化 for(int b=1;b<defen.length-1;b++) { for(int a=0;a<defen.length-b;a++) { if(defen[a]>defen[a+1]) { int t=defen[a]; defen[a]=defen[a+1]; defen[a+1]=t; }} for (int a=0;a<defen.length;a++) {System.out.print(defen[a]+"\t");} System.out.println(); } //第二步,冒泡输出,排列顺序 int zuizhongdefen=(defen[3]+defen[4]+defen[5] +defen[6]+defen[7]+defen[8])/6; System.out.print("选手最后得分是"+zuizhongdefen); //第三步,去掉两个最高分,两个最低分,求剩余分值的平均分
时间: 2024-10-12 11:32:07