ArrayList<int[]> lottoraws= new ArrayList<int[]>();
int[] a = new int[5];
int[] b = new int[7];
for (int i = 0; i < 7; i++) {
int rand = (int) (Math.random() * 35 + 1);
b[i] = rand;
for (int j = 0; j < 5; j++) {
int rand2 = (int) (Math.random() * 35 + 1);
a[j] = rand2;
}
}
lottoraws.add(a);
lottoraws.add(b);
System.out.println("The players row: \n" + Arrays.toString(lottoraws.get(0)));
答案 0 :(得分:0)
那样的东西?
int[][] a = new int[7][5];
for (int i = 0; i < a.length; i++) {
for(int j = 0; j < a[0].length ; j++){
a[i][j] = (int) (Math.random() * 35 + 1);
}
}
答案 1 :(得分:0)
请尝试以下操作,您可以根据需要更改随机方案。
ArrayList<int[]> lottoraws = new ArrayList<int[]>();
int[] a = {};
Random random = new Random();
for (int i = 0; i < 7; i++) {
a = new int[5];
for (int j = 0; j < 5; j++) {
int rand2 = (int) (random.nextInt(200));
a[j] = rand2;
}
lottoraws.add(a);
}
for(int k=0; k< lottoraws.size(); k++){
System.out.println(Arrays.toString(lottoraws.get(k)));
}
}