体彩大乐透

CSDN新人入伙,请多关照!代码仅供参考!
切记不要白嫖哈!!!记得点赞o
其中的一些代码逻辑全是靠着自己在大乐透的往期中奖号码当中寻找的一些规律,并且这只是模仿大乐透的一点简单原理,希望各位童鞋不要使用这个计算出来的号码去买大乐透,买了不中你可别来找我啊!!!重要的事情加三个感叹号。
当然了,如果有大神能帮忙指出代码中的不足也是万分的感谢!!!

@RequestMapping(value = "/thelotto" , method = RequestMethod.GET)
public List TheLotto(){
    List<String> list = new ArrayList<>();
    String theLotto = null ;
    int w = 0;
    do {
        //前五位数
        int [] arr = {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 [] brr = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
        //产生0-(arr.length-1)的整数值,也是数组的索引
        int a1 = (int)(Math.random()*arr.length);
        int a2 = (int)(Math.random()*arr.length);
        int a3 = (int)(Math.random()*arr.length);
        int a4 = (int)(Math.random()*arr.length);
        int a5 = (int)(Math.random()*arr.length);
        int b1 = (int)(Math.random()*brr.length);
        int b2 = (int)(Math.random()*brr.length);
        //根据下标取出对应的值
        int s1 = arr[a1];
        int s2 = arr[a2];
        int s3 = arr[a3];
        int s4 = arr[a4];
        int s5 = arr[a5];
        int c1 = arr[b1];
        int c2 = arr[b2];
        //保证前五位数的不同及升序,后两位数的不同及升序
        if(s1!=s2 && s1!=s3 && a1!=s4 && s1!=s5 && s1<s2 && s1<s3 && s1<s4 && s1<s5){
            if(s2!=s3 && s2!=s4 && s2!=s5 && s2<s3 && s2<s4 && s2<s5){
                if(s3!=s4 && s3!=s5 && s3<s4 && s3<s5){
                    if(s4!=s5 && c1!=c2 && s4<s5 && c1 < c2){

                        theLotto = s1+" "+s2+" "+s3+" "+s4+" "+s5+" "+c1+" "+c2;
                        //添加到list
                        list.add(theLotto);
                        w = w+1;
                    }
                }
            }
        }
        //在list集合当中增加一百条数据
    }while (w < 100);
    // 遍历 List 集合中的一百条数据
    //for (int i = 0 ; i < list.size() ; i++){
    //    System.out.println(list.get(i));
    //}

    List<String> newTheLotto = new ArrayList<>();
    int s = 0;
    do {
        //随机获取list集合中100条数据中的其中5条数据
        String s1 = list.get((int)(1+Math.random()*(10-1+1)));
        String s2 = list.get((int)(1+Math.random()*(10-1+1)));
        String s3 = list.get((int)(1+Math.random()*(10-1+1)));
        String s4 = list.get((int)(1+Math.random()*(10-1+1)));
        String s5 = list.get((int)(1+Math.random()*(10-1+1)));
        //判断五组数据不能相同
        if(!s1.equals(s2) && !s1.equals(s3) && !s1.equals(s4) && !s1.equals(s5)){
            if(!s2.equals(s3) && !s2.equals(s4) && !s2.equals(s5)){
                if(!s3.equals(s4) && !s3.equals(s5)){
                    if(!s4.equals(s5)){
                        newTheLotto.add(s1);
                        newTheLotto.add(s2);
                        newTheLotto.add(s3);
                        newTheLotto.add(s4);
                        newTheLotto.add(s5);
                        s = s+1;
                    }
                }
            }
        }
    }while (s<1);
    return newTheLotto;
}
  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值