public class DoubleBall {
public void produceNum() {
Random random = new Random();
int[] in = new int[7];
int count = 0;
/*for (int i = 0; i < 6; i++) {
in[i] = (random.nextInt(32)+1);
int num = (random.nextInt(32)+1);
}*/
while(count < 7) {
int num = (random.nextInt(32)+1);
boolean flag = true;
for (int i=0; i<count; i++) {
if (num == in[i]) {
flag = false;
break;
}
}
if (flag) {
in[count] = num;
count++;
}
}
//Arrays.sort(in);
in[6] = random.nextInt(15)+1;
Arrays.sort(in,0,5);
for (int i = 0; i < in.length; i++) {
System.out.print(in[i]+" ");
}
}
public static void main(String[] args) {
DoubleBall doubleBall = new DoubleBall();
doubleBall.produceNum();
}
}
模仿双色球进行生成号码
最新推荐文章于 2024-07-09 20:33:22 发布