...老师留的结业题 用java编译道关于双色球的代码 要求:(红球33选1...
发布网友
发布时间:2024-10-22 07:26
我来回答
共4个回答
热心网友
时间:2024-11-17 10:05
双色球红球是33选6,下面是电脑机选代码:
/**
* 实现生成 双色球彩票号码 算法
*
* 实现方法 返回彩票号码 如:[03, 06, 08, 12, 15, 23, 28]
*
* 1) 生成红球号码
* 数据 红球 :"01" ~ "33"
* 使用标记: f, f, ...
* 红球号 : { ^, ^, ^, ^, ^, ^}
* index = 0 生成号码的个数
* 2) 生成蓝色球号码
*/
public class Demo10 {
public static void main(String[] args) {
String[] balls = gen();
System.out.println(Arrays.toString(balls));
}
public static String[] gen(){
String[] pool = {"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"};
boolean[] used = new boolean[pool.length];
String[] balls = new String[6];
int index = 0;
Random r = new Random();
do{
int i = r.nextInt(pool.length);
if(used[i]){ continue; }
balls[index++] = pool[i];
used[i] = true;
}while(index!=balls.length);
Arrays.sort(balls);
//扩容,追加蓝色球号码
balls = Arrays.copyOf(balls, balls.length+1);
balls[balls.length-1] = pool[r.nextInt(16)];
return balls;
}
}
热心网友
时间:2024-11-17 10:01
这样麻烦的程序个人感觉是不会有人特意为你写的,除非是那种有报酬的,或者自己以前写过一样的游戏才会在百度知道里面给你的,如果你有钱,可以去淘宝或者csdn上面花钱雇人写吧
热心网友
时间:2024-11-17 10:04
这样麻烦的程序个人感觉是不会有人特意为你写的,除非是那种有报酬的,或者自己以前写过一样的游戏才会在百度知道里面给你的,如果你有钱,可以去淘宝或者csdn上面花钱雇人写吧
希望能解决您的问题。
热心网友
时间:2024-11-17 10:04
这个我倒是可以给你个现成的参考一下,你扣扣 不要了么 ,你在加点分给我 给我个邮箱我给你发过去