package com.softeem;
import java.util.Arrays;
import java.util.Random;
/**
*
* <p>Title: DoubleColorBall</p>
* <p>Description:
* 双色球:
* 红-[1,33]-------6
* 蓝-[1,16]-------1
*
* </p>
* @author LiXiuYong
* @date 2020年12月8日
*/
public class DoubleColorBall {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("双色球开奖");
Random r=new Random();
int blue=r.nextInt(16)+1;
System.out.println(blue);
int[] redBalls=new int[6];
int[] balls= {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,
21,22,23,24,25,26,27,28,29,30,31,32,33};
boolean[] flag=new boolean[balls.length];
for(int i=0;i<redBalls.length;i++) {
int k=0;
do {
k=r.nextInt(33);
}while(flag[k]);
flag[k]=true;
redBalls[i]=balls[k];
}
//扩容前排序
Arrays.sort(redBalls);
//扩容
redBalls=Arrays.copyOf(redBalls, redBalls.length+1);
redBalls[redBalls.length-1]=blue;
System.out.println("红色号码为:"+Arrays.toString(redBalls));
}
}
2020-12-13
最新推荐文章于 2024-08-23 00:00:00 发布