双色球系统

package com.li;

import java.util.Random;
import java.util.Scanner;

public class demo813 {
    public static void main(String[] args) {
        int[] b=cai();
        int[] a=zj();
        jieguo(b,a);

    }

    public static int[] zj() {
        Random b = new Random();
        int[] a = new int[7];
        for (int i = 0; i < a.length - 1; i++) {
            a[i] = b.nextInt(33)+1;
        }
        a[a.length - 1] = b.nextInt(16)+1;
        for (int i = 0; i < a.length - 1; i++) {
            int r = i + 1;
            OUT:
            while (r < a.length - 1) {
                if (a[i] == a[r]) {
                    a[i] = b.nextInt(33)+1;
                    i = -1;
                    break OUT;
                } else r++;
            }
        }
        for (int i = 0; i < a.length; i++) {
            System.out.println(a[i]);
        }

        return a;

    }

    public static int[] cai() {
        Scanner a = new Scanner(System.in);
        int[] b = new int[7];
        for (int i = 0; i < 7 ; i++) {
            b[i] = a.nextInt();
        }
        return b;
    }

    public static void jieguo(int[] a,int[] b) {
//        int[] a = zj();
//        int[] b = cai();
        int c = 0;
        int d = 0;
        for (int i = 0; i < 6; i++) {
            if (a[i] == b[i]) {
                c++;
            }
        }
        if (a[6] == b[6]) d = 1;
        switch (c) {
            case 6:
                switch (d) {
                    case 1:
                        System.out.println("恭喜获得一等奖");
                        break;
                    case 0:
                        System.out.println("恭喜获得二等奖");
                        break;
                }
            case 5:
                switch (d) {
                    case 1:
                        System.out.println("恭喜获得三等奖");
                        break;
                    case 0:
                        System.out.println("恭喜获得四等奖");
                        break;
                }
            case 4:
                switch (d) {
                    case 1:
                        System.out.println("恭喜获得四等奖");
                        break;
                    case 0:
                        System.out.println("恭喜获得五等奖");
                        break;
                }
            case 3:
                switch (d) {
                    case 1:
                        System.out.println("恭喜获得五等奖");
                        break;
                    case 0:
                        System.out.println("很遗憾,未获奖");
                        break;
                }
            case 2:
                switch (d) {
                    case 1:
                        System.out.println("恭喜获得五等奖");
                        break;
                    case 0:
                        System.out.println("很遗憾,未获奖");
                        break;
                }
            case 1:
                switch (d) {
                    case 1:
                        System.out.println("恭喜获得六等奖");
                        break;
                    case 0:
                        System.out.println("很遗憾,未获奖");
                        break;
                }
            case 0:
                switch (d) {
                    case 1:
                        System.out.println("恭喜获得六等奖");
                        break;
                    case 0:
                        System.out.println("很遗憾,未获奖");
                        break;
                }

        }
    }
}

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值