大乐透,双色球随机生成

it2026-09-01  6

在外面出差每天吃早饭的时候旁边就是体彩店,我一进去对选号就头疼,晚上没事索性就写了一个小程序,运行下自动生成,

我哥哥也是个彩票迷,经常让我选号他买,这下好了,不要头疼想了,哈哈,还有彩票买了权当做福利事业了就行了,平常心对待,小赌怡情嘛。

备注:随机生成的没有排序哦,交给彩票店老板他自己会打的。

   //大乐透 5+2 随机生成

   public static void main(String[] args) {         int[] before = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35};         int[] after={1,2,3,4,5,6,7,8,9,10,11,12};         String number="";         int temp;         //前五位         for(int index=0;index<5;index++){             double m=(Math.random()*before.length);                if(m<1){                 temp =(int) Math.floor(m*10);             }else{                 temp =(int) Math.floor(m);             }             number+=temp+",";         }                  //后两位         for(int index=0;index<2;index++){             double n=(Math.random()*after.length);                if(n<1){                 temp =(int) Math.floor(n*10);             }else{                 temp =(int) Math.floor(n);             }             number+=temp+",";         }         //截取字符串,去掉最后一个逗号         number=number.substring(0, number.length()-1);         System.out.println(number); }

     //双色球 6+1 随机生成

       public static void main(String[] args) {             int[] before = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33};             int[] after={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16};             String number="";             int temp;             //前六位             for(int index=0;index<6;index++){                 double m=(Math.random()*before.length);                    if(m<1){                     temp =(int) Math.floor(m*10);                 }else{                     temp =(int) Math.floor(m);                 }                 number+=temp+",";             }             //后一位             for(int index=0;index<1;index++){                 double n=(Math.random()*after.length);                    if(n<1){                     temp =(int) Math.floor(n*10);                 }else{                     temp =(int) Math.floor(n);                 }                 number+=temp+",";             }                          //截取字符串,去掉最后一个逗号             number=number.substring(0, number.length()-1);             System.out.println(number);                }

转载于:https://www.cnblogs.com/weiyi1314/p/6648350.html

相关资源:彩票号码随机生成程序
最新回复(0)