package com.heima.java1024.tests;
import java.util.Arrays;
import java.util.Random;
public class DoubleColorBall {//toString()
public static void main(String[] args) {
for(int i =1;i<=75;i++) {
System.out.println(create());
}
}
public static String create() {
//String[] red = new String[33];
String[] red = {"01","02","03","04","05","06","07","08","09","10",
"11","12","13","14","15","16","17","18","19","20","21","22","23",
"24","25","26","27","28","29","30","31","32","33"};
String[] blue = "01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16".split(",");
boolean[] used = new boolean[red.length];
Random r = new Random();
String[] all = new String[7];
for(int i = 0;i<6;i++) {
int idx;
do {
idx = r.nextInt(red.length);//0-32
} while (used[idx]);//如果使用了继续找下一个
used[idx] = true;//标记使用了
all[i] = red[idx];//取出一个未使用的红球
}
all[all.length-1] = "99";
//System.out.println(Arrays.toString(all));
Arrays.sort(all);
all[all.length-1] = blue[r.nextInt(blue.length)];
return Arrays.toString(all);
}
}
嘿嘿,小小程序,希望各位大神帮帮忙 ,修改的更完美一点 |
|