双色球号码生成器 - 免费在线生成随机号码
import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.Random; import java.util.Scanner;
public class DoubleColorBallGenerator {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println('请输入购买的双色球注数:');
int n = sc.nextInt();
for (int i = 1; i <= n; i++) {
List
// 生成6个红球
private static List<Integer> generateRedBalls() {
List<Integer> redBalls = new ArrayList<>();
Random random = new Random();
while (redBalls.size() < 6) {
int ball = random.nextInt(33) + 1;
if (!redBalls.contains(ball)) {
redBalls.add(ball);
}
}
Collections.sort(redBalls);
Iterator<Integer> it = redBalls.iterator();
while (it.hasNext()) {
System.out.print(it.next() + ' ');
}
System.out.println();
return redBalls;
}
// 生成1个蓝球
private static int generateBlueBall() {
Random random = new Random();
int blueBall = random.nextInt(16) + 1;
System.out.println('蓝球号码为:' + blueBall);
return blueBall;
}
}
原文地址: https://www.cveoy.top/t/topic/okyO 著作权归作者所有。请勿转载和采集!