zoukankan      html  css  js  c++  java
  • java排序。。。

    题目:n位学生,m位评委,去掉一个最高分,和一个最低分,选手最后得分

    package com.aini;
    
    import java.util.Arrays;
    
    public class WDS {
    	int a[][];
    
    	public void grade(int n, int m) {
    		a = new int[n][m];
    		for (int i = 0; i < n; i++)
    			// 对每一位选手打分
    			for (int j = 0; j < m; j++)
    				a[i][j] = 50 + (int) (Math.random() * 50.0);
    		for (int i1 = 0; i1 < n; i1++) {
    			Arrays.sort(a[i1]);// 对每一位选手的得分排序
    			System.out.println((i1 + 1) + ".");
    			int total = 0;// 统计每一位选手的得分,去掉一个最高分和一个最低分
    			for (int j1 = 0; j1 < m - 1; j1++) {
    				System.out.println(a[i1][j1] + " ");
    				// 输出各位评委的打}
    				total += a[i1][j1];
    				System.out.println((float) total / m - 2 + " 
    ");// 最终得分
    
    			}
    		}
    	}
    }
    //测试类
    package com.aini;
    
    public class Test {
    	public static void main(String[] args) {
    		WDS d = new WDS();
    		d.grade(90, 30);
    		// System.out.println(d.grade(10, 20));
    	}
    
    }
    

      

  • 相关阅读:
    @SpringBootApplication注解的理解
    git详解
    什么是maven?
    redis发布订阅实战
    报文示例
    Cisco的ACI究竟是什么?它和SDN有关系吗?
    IP数据包分析
    ARP数据包分析
    水冷精密空调工作原理
    风冷精密空调工作原理
  • 原文地址:https://www.cnblogs.com/langlove/p/3404118.html
Copyright © 2011-2022 走看看