public static void main(String[] args) {
lottery();
}
public static void lottery(){
int[] arr = new int[6];
int[] arr1 = new int[2];
int i=0;
int x=0;
a:for (; i < arr.length;) {
arr[i]=(int)(Math.ceil(35*(Math.random())));
for (int j = i-1; j >=0 ; j--) {
if(arr[i]==arr[j])
continue a;
}
System.out.print(arr[i]+" ");
i++;
}
b:for (; x < arr1.length; ) {
arr1[x]=(int)(Math.ceil(12*(Math.random())));
for (int y = x-1; y >= 0; y--) {
if (arr1[x]==arr1[y])
continue b;
}
System.out.print(" "+arr1[x]);
x++;
}
}
大神若发现漏洞,望指出。谢谢!!! |
|