1-49,随机生成6个不相同的数值
int[] number = new int[6]; for (int j=0;j<number.length;j++){ int k = (int) Math.ceil(Math.random()*49); number[j] = k; if(j >= 1){ for(int m = j;m>0;j--){ if(number[m] == number[j])break; } } System.out.println(number[j]); }
1-49,随机生成6个不相同的数值
int[] number = new int[6]; for (int j=0;j<number.length;j++){ int k = (int) Math.ceil(Math.random()*49); number[j] = k; if(j >= 1){ for(int m = j;m>0;j--){ if(number[m] == number[j])break; } } System.out.println(number[j]); }