[20-04-30][Self-test 25]Java MaxAndMin

2021-02-02 04:16

阅读:723

标签:system   print   stat   max   一个   out   span   java   dmi   

 1 package test_5_2;
 2 
 3 public class MaxAndMin {
 4 
 5     public static void main(String[] args) {
 6 
 7         /** 有10个分,去掉一个最高一个最低求平均分 */
 8         int[] numArr = {99, 97, 96, 95, 94, 92, 91, 90, 88, 100};
 9         
10         for (int i = 0; i ) {
11             numArr[i] = numArr[i];
12         }
13         
14         for (int i = 0; i ) {
15             for (int j = i + 1; j ) {
16                 if (numArr[i]  numArr[j]) {
17                     int temp = numArr[i];
18                     numArr[i] = numArr[j];
19                     numArr[j] = temp;
20                 }
21             }
22         }
23         
24         int sum = 0;
25         for (int i = 1; i ) {
26             sum += numArr[i];
27         }
28         
29         System.out.println("去掉最高最低分后平均分为:" + sum * 1.0 / (numArr.length - 2));
30         
31         
32     }
33 
34 }

 

结果如下:

去掉最高最低分后平均分为:94.25

[20-04-30][Self-test 25]Java MaxAndMin

标签:system   print   stat   max   一个   out   span   java   dmi   

原文地址:https://www.cnblogs.com/mirai3usi9/p/12811483.html


评论


亲,登录后才可以留言!