Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试编写一种方法来计算 [0....range) 范围内的 num 个随机整数并将频率放入 arr[] 中。
public static void doSingleTest(int[] arr, int num, int range){ for (int i=1; i<=num; i++){ int random = randomInteger(int a, int b); arr[random]++; }
也许你想初始化你的数组:
int[] arr = new int[range];
然后在你的方法中:
public static void doSingleTest(int[] arr, int num, int range){ for (int i = 1; i <= num; i++){ int r= randomInteger(0, range); arr[r]++; }