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