java实现双色球机选 *
作者:绿荫夏遮阳 时间:2022-10-05 07:41:33
本文实例为大家分享了java实现双色球机选 * 的具体代码,供大家参考,具体内容如下
双色球号码1~32不重复选6个(排序好),1~16中选一个(蓝号)
import java.util.Random;
import java.util.Arrays; //操作数组的工具类
/**
* 双色球号码机选
*
* @author Administrator
*
*/
public class Lettery {
public static void main(String[] args) {
for (int i = 0; i < 5; i++) {
int[] nos = create();
// System.out.println(nos);
System.out.println(Arrays.toString(nos));
}
}
/**
* 机选一注
*
* @return
*/
public static int[] create() {
int[] nos = new int[7];
Random r = new Random();
LoopI: for (int i = 0; i < 6; ) {
nos[i] = r.nextInt(32) + 1;
// 先生成再用当前数字与之前产生的数字比较找重复
for (int j = 0; j < i; j++) {
if (nos[i] == nos[j]) {
// System.out.println("第" + (i + 1) + "数字:" + nos[i] + "与第" + (j + 1) + "个数字重复了");
continue LoopI;
}
}
i++;
}
nos[6] = r.nextInt(16) + 1;
Arrays.sort(nos,0,6); //对数组的前6位排序
return nos;
}
public static void printArray(int[] arrays) {
for (int i = 0; i < arrays.length; i++) {
System.out.print(arrays[i] + ", ");
}
}
}
来源:https://blog.csdn.net/lvyinxiazheyang/article/details/52000095
标签:java,双色球,号码
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
使用springboot打包成zip部署,并实现优雅停机
2021-08-04 20:45:01
![](https://img.aspxhome.com/file/2023/0/87200_0s.jpg)
C#实现系统托盘通知的方法
2023-04-17 08:40:02
java和 javaw 及 javaws的区别解析
2023-07-21 06:31:05
![](https://img.aspxhome.com/file/2023/9/64749_0s.png)
C# winform点击生成二维码实例代码
2023-12-10 08:17:20
![](https://img.aspxhome.com/file/2023/8/106418_0s.png)
Java中的Object类用法总结
2023-06-06 11:48:36
![](https://img.aspxhome.com/file/2023/0/101910_0s.png)
C#中Winform窗体Form的关闭按钮变灰色的方法
2023-06-06 09:11:34
java多线程之线程同步七种方式代码示例
2022-04-29 17:55:46
浅谈JAVA 内存流的实现
2021-06-28 05:43:59
![](https://img.aspxhome.com/file/2023/5/86815_0s.jpg)
C#泛型的使用案例
2023-10-01 23:24:00
java使用淘宝API读写json实现手机归属地查询功能代码
2021-05-31 03:27:38
基于SpringBoot Mock单元测试详解
2021-09-25 02:49:41
![](https://img.aspxhome.com/file/2023/0/108410_0s.png)
java中的JsonSerializer用法,前后端单位转换必备
2022-05-01 07:58:48
![](https://img.aspxhome.com/file/2023/4/64904_0s.jpg)
C# 使用 Castle 实现 AOP及如何用 Autofac 集成 Castle
2023-07-08 16:02:26
android电源信息查看(电量、温度、电压)实例代码
2022-04-30 15:41:04
C#多线程Thread使用示例详解
2021-11-12 06:52:05
![](https://img.aspxhome.com/file/2023/6/104376_0s.jpg)
spring boot容器启动流程
2023-02-17 09:25:36
![](https://img.aspxhome.com/file/2023/3/77143_0s.png)
android简单自定义View实现五子棋
2023-06-01 19:30:38
![](https://img.aspxhome.com/file/2023/3/123263_0s.jpg)
JAVA常用API总结与说明
2023-05-19 08:17:17
C#多线程系列之线程通知
2023-09-13 17:08:03
![](https://img.aspxhome.com/file/2023/4/96304_0s.jpg)
解决SpringBoot跨域的三种方式
2021-06-20 13:20:08