import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Random;

public class DoubleColorBallGenerator { public static void main(String[] args) { List redBalls = new ArrayList<>(); Random random = new Random(); for (int i = 0; i < 6; i++) { int redBall = random.nextInt(33) + 1; while (redBalls.contains(redBall)) { redBall = random.nextInt(33) + 1; } redBalls.add(redBall); } Collections.sort(redBalls); int blueBall = random.nextInt(16) + 1; System.out.println('双色球号码为:' + redBalls.toString() + ' + ' + blueBall); } }

Java 双色球号码生成器 - 随机生成彩票号码

原文地址: https://www.cveoy.top/t/topic/okyS 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录