晚上好,我想用不同的数字填充一个五 x 五的表格避免表中的数字不超过一次
int num;
int [][] array = new int [5][5];
Random r = new Random();
for (int row = 0; row < array.length; row++) {
for (int col = 0; col < array[row].length; col++) {
if(row == 0){
num =r.nextInt(15);
array[row][col]=num;
}else if(row == 1){
num =r.nextInt(31-16)+16;
array[row][col]=num;
}else if(row == 2){
num =r.nextInt(45-31)+31;
array[row][col]=num;
}else if(row == 3){
num =r.nextInt(61-46)+46;
array[row][col]=num;
}else if(row == 4){
num =r.nextInt(75-61)+61;
array[row][col]=num;
}
}
}