java随机生成双色球幸运号码
时间: 2023-11-29 11:45:37 浏览: 187
以下是Java随机生成双色球幸运号码的代码示例:
```java
import java.util.Arrays;
import java.util.Random;
public class DoubleColorBall {
public static void main(String[] args) {
int[] redBalls = new int[33];
for (int i = 0; i < redBalls.length; i++) {
redBalls[i] = i + 1;
}
int[] selectedRedBalls = new int[6];
Random random = new Random();
for (int i = 0; i < selectedRedBalls.length; i++) {
int index = random.nextInt(redBalls.length - i);
selectedRedBalls[i] = redBalls[index];
redBalls[index] = redBalls[redBalls.length - i - 1];
}
Arrays.sort(selectedRedBalls);
int selectedBlueBall = random.nextInt(16) + 1;
System.out.println("红球:" + Arrays.toString(selectedRedBalls));
System.out.println("蓝球:" + selectedBlueBall);
}
}
```
阅读全文
相关推荐
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![-](https://img-home.csdnimg.cn/images/20241231045053.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![text/x-java](https://img-home.csdnimg.cn/images/20250102104920.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)