import java.util.Arrays;import java.util.Random;public class demo01 { public static void main(String[] args) { int[][] arrays = new int[100][7]; Random ran = new Random(); boolean flag =true; int num = ran.nextInt(33)+1; for (int i = 0; i < arrays.length; i++) { // i控制输出打印100行 for (int j = 0; j < arrays[i].length; j++) { if (j < 6) {// j控制元素里一共有7个值 arrays[i][j] = ran.nextInt(33) + 1; } else arrays[i][j] = ran.nextInt(16) + 1; for(int k = 0;k<arrays[i].length-1;k++) { if(num==arrays[i][j]&&j<6) { flag=true; i--; break; }flag=false; } if(!flag) {num=arrays[i][j];}} System.out.println("当前第" + (i + 1) + "行" + Arrays.toString(arrays[i])); } }}运行出来的结果是有重复值的,求解!
添加回答
举报
0/150
提交
取消