如下数据是何种编码?如何转换?
发布网友
发布时间:2023-10-20 23:01
我来回答
共1个回答
热心网友
时间:2024-11-19 03:30
代码如下:
import java.util.Random;
class ArrayStats {
public static int[] createRandomArray(int length, int bound) {
Random random = new Random(System.currentTimeMillis());
int[] array = new int[length];
for (int i = 0; i < array.length; i++) {
array[i] = random.nextInt(bound) + 1;
}
return array;
}
}
public class App59 {
public static void main(String[] args) {
int[] a = ArrayStats.createRandomArray(5, 10);
printArray(a);
int[] b = ArrayStats.createRandomArray(10, 100);
printArray(b);
int[] c = ArrayStats.createRandomArray(15, 1000);
printArray(c);
int[] d = ArrayStats.createRandomArray(20, 10);
printArray(d);
int[] e = ArrayStats.createRandomArray(20, 6);
printArray(e);
}
static void printArray(int[] array) {
for (int val : array) {
System.out.print(val + " ");
}
System.out.println();
}
}
来自:求助得到的回答