双色球
package day0601_作业;
import java.util.Arrays;
import java.util.Random;
public class Test1双色球 {
public static void main(String[] args) {
int[] a = random(33,33);
int[] b = ssq(a);
Arrays.sort(b);
int n = (int)(1 + Math.random()*16);
System.out.println(Arrays.toString(b)+n);
}
private static int[] ssq(int[] a) {
int[] c = new int[6];
for(int i=0;i<6;i++) {
c[i] = a[i];
}
return c;
}
private static int[] random(int t,int k) {//t需要 生成数组长度,k随机数取值范围
int[] a = new int[t];
int n;
boolean flag;
for (int i = 0; i < a.length; i++) {
do {
flag = false;
n = 1 + new Random().nextInt(k);
for (int j = 0; j <= i; j++) {
if (n == a[j]) {
flag = true;
break;
}
}
} while (flag);
a[i] = n;
}
return a;
}
}