双色球生成n个不同整数

package day0601_作业;

import java.util.Arrays;
import java.util.Random;

public class Test2双色球 {
public static void main(String[] args) {
int[] a = new int[33];
for (int i = 0; i < a.length; i++) {
a[i] = i + 1;
}
// System.out.println(Arrays.toString(a));
for(int j=0;j<6;j++) {
int n = new Random().nextInt(33);
int t = a[j];
a[j] = a[n];
a[n] = t;
}
int[] b = Arrays.copyOf(a, 6);
int n = 1 + new Random().nextInt(16);
System.out.println(Arrays.toString(b)+" "+n);
}
}

posted @ 2018-12-09 16:04  Java大笨鸟  阅读(216)  评论(0编辑  收藏  举报