public static void main(String[] args) {
// 使用random类随机6个1到33的红球(不重复)和1个1到16的蓝球(模拟双色球彩票)
Random r = new Random();
//定义一个数组装球
int[] arr = new int[7];
//判断是否有重复,有重复就重新随机取值,无重复就将数值存入数组中
for (int i = 0; i < arr.length-1; i++) {
int a = r.nextInt(33)+1;
for (int j = 0; j < i; j++) {
if(a == arr[j]){
a = r.nextInt(33)+1;
j--;
}
}
arr[i] = a;
}
arr[arr.length-1] = r.nextInt(16)+1;
for (int i = 0; i < arr.length; i++) {
System.out.println(arr[i]);
}