Java 双色球号码生成器 - 随机生成彩票号码
import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.Random;
public class DoubleColorBallGenerator {
public static void main(String[] args) {
List
public static List<Integer> generateRedBalls() {
List<Integer> redBalls = new ArrayList<>();
Random random = new Random();
while (redBalls.size() < 6) {
int redBall = random.nextInt(33) + 1;
if (!redBalls.contains(redBall)) {
redBalls.add(redBall);
}
}
return redBalls;
}
public static int generateBlueBall() {
Random random = new Random();
return random.nextInt(16) + 1;
}
public static void output(List<Integer> redBalls, int blueBall) {
System.out.print('双色球号码:');
Iterator<Integer> iterator = redBalls.iterator();
while (iterator.hasNext()) {
System.out.print(iterator.next() + ' ');
}
System.out.print('+ ' + blueBall);
}
}
原文地址: https://www.cveoy.top/t/topic/okxJ 著作权归作者所有。请勿转载和采集!