隨機生成指定範圍、數量的隨機數方法

從網上找到的,原方法生成的隨機數數量會比指定的小,在循環中加入判斷後正常 public static void randomSet(int min, int max, int n, HashSet<Integer> set) { if (n > (max - min + 1) || max < min) { return; } for (int i = 0;
相關文章
相關標籤/搜索