zoukankan      html  css  js  c++  java
  • 给一段时间内的一组人随机排班的问题

    问题描述如下:

    已知有number个人,需要值班的天数为length天,需要每一轮都进行随机排序。

    具体的代码如下:

     1     /**
     2      * 按照length天 给number人排班
     3      */
     4     public static void scheduleInfo(int number,int length){
     5         for (int i = 0; i <= length; i++) {
     6             List<String> operateList = Stream.of("A", "B", "C", "D", "E").collect(Collectors.toList());
     7             for (int j = number; j > 0 && i <= length; j--, i++) {
     8                 Integer numNum = RandomUtils.nextInt(0, operateList.size());
     9                 System.out.println("随机数number是:" + numNum + "map中的值是:" + operateList.get(numNum));
    10                 operateList.remove(operateList.get(numNum));
    11             }
    12         }
    13     }
    14 
    15 
    16     public static void main(String[] args) {
    17         scheduleInfo(5,6);
    18 
    19     }
  • 相关阅读:
    自定义长时间定时器对象
    poj1326
    poj1323
    poj1218
    poj1298
    poj1276
    新年的第一场雪
    Java 语言学习总结
    假使时光能够倒转
    为了回家——春运3日战纪实
  • 原文地址:https://www.cnblogs.com/cswxl/p/14329927.html
Copyright © 2011-2022 走看看