问题描述如下:
已知有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 }