/*1.双色球投注时至少选择6个红球(1-33号)和一个蓝球(1-16号)。每注红球号不重复。
如:红球为 01 07 09 15 23 29 蓝球为08。
。显示格式如:
第一注:红球: 01 07 09 15 23 29 蓝球: 08
第二注:红球: 01 05 09 19 23 29 蓝球: 04*/
public static void main(String[] args) {
List list=new ArrayList();
List list2=new ArrayList();
for(int i=01;i<34;i++){
list.add(i);
}
Collections.shuffle(list);
for(int j=1;j<=6;j++){
list2.add(list.get(j-1));
}
Collections.sort(list2);
for(Object o:list2){
if((int)o<10){
System.out.print("0"+o+"\t");
}else{
System.out.print(o+"\t");
}
}
int x=(int)(1+Math.random()*18);
if(x<10){
System.out.print("0"+x+"\t");
}else{
System.out.print(x+"\t");
}
}
如:红球为 01 07 09 15 23 29 蓝球为08。
。显示格式如:
第一注:红球: 01 07 09 15 23 29 蓝球: 08
第二注:红球: 01 05 09 19 23 29 蓝球: 04*/
public static void main(String[] args) {
List list=new ArrayList();
List list2=new ArrayList();
for(int i=01;i<34;i++){
list.add(i);
}
Collections.shuffle(list);
for(int j=1;j<=6;j++){
list2.add(list.get(j-1));
}
Collections.sort(list2);
for(Object o:list2){
if((int)o<10){
System.out.print("0"+o+"\t");
}else{
System.out.print(o+"\t");
}
}
int x=(int)(1+Math.random()*18);
if(x<10){
System.out.print("0"+x+"\t");
}else{
System.out.print(x+"\t");
}
}
本文介绍了一个简单的双色球随机选号程序实现方法。该程序能够从1-33中随机选取6个不重复的红球号码,并从1-16中选取1个蓝球号码。通过Java的集合操作确保了号码的独特性和随机性。
6万+

被折叠的 条评论
为什么被折叠?



