package ch7;

public class ch7_9 
{
    public static void main(String awgs[])
    {
        int bun[]= {2,3,22,28,29,30,39};
        int h1[]= {2,3,22,28,29,39};
        int r1[]=new int[6];
        int a=0,b=0,c=0,d=0,e=0;
        for(a=0;a<=5;a++)
        {
            r1[a]=(int)(Math.random()*39)+1;
        }
        for(a=0;a<=4;a++)
        {
            for(b=0;b<=4;b++)
            {
                if(r1[b]>r1[b+1])
                {
                    c=r1[b+1];
                    r1[b+1]=r1[b];
                    r1[b]=c;
                }
            }
        }
        for(a=0;a<=5;a++)
        {
            System.out.print(r1[a]+",");    
        }
        System.out.println();
        c=0;
        for(a=0;a<=6;a++)
        {
            if (a==6)
            {
                if(h1[c]==bun[a])
                {
                    e=e+1;
                }
            }
            else
            {
                if(h1[c]==bun[a])
                {
                    d=d+1;
                }
                if(h1[c]<=bun[a])
                {
                    c=c+1;
                }
            }
        }
        System.out.println("小名中了什麼獎呢?");
        if(e==1)
        {
            if(d==5)
            {
                System.out.println("中了五個號碼加特別號!二獎!");    
            }
        }
        else
        {
            switch (d)
            {
            case 0:
                break;
            case 1:
                break;
            case 2:
                break;
            case 3:
                System.out.println("中了三個號碼!五獎!");
                break;
            case 4:
                System.out.println("中了四個號碼!四獎!");
                break;
            case 5:
                System.out.println("中了五個號碼!三獎!");
                break;
            case 6:
                System.out.println("中了六個號碼!頭獎!");    
                break;
            }
        }
        a=0;
        b=0;
        c=0;
        d=0;
        e=0;
        for(a=0;a<=6;a++)
        {
            if (a==6)
            {
                if(r1[c]==bun[a])
                {
                    e=e+1;
                }
            }
            else
            {
                if(r1[c]==bun[a])
                {
                    d=d+1;
                }
                if(r1[c]<=bun[a])
                {
                    c=c+1;
                }
            }
        }
        System.out.println("小王中了什麼獎呢?");
        if(e==1)
        {
            if(d==5)
            {
                System.out.println("中了五個號碼加特別號!二獎!");    
            }
            switch (d)
            {
            case 0:
                System.out.println("沒中");
                break;
            case 1:
                System.out.println("沒中!");
                break;
            case 2:
                System.out.println("沒中!!");
                break;
            case 3:
                System.out.println("中了三個號碼!五獎!");
                break;
            case 4:
                System.out.println("中了四個號碼!四獎!");
                break;
            }
        }
        else
        {
            switch (d)
            {
            case 0:
                System.out.println("沒中");
                break;
            case 1:
                System.out.println("沒中!");
                break;
            case 2:
                System.out.println("沒中!!");
                break;
            case 3:
                System.out.println("中了三個號碼!五獎!");
                break;
            case 4:
                System.out.println("中了四個號碼!四獎!");
                break;
            case 5:
                System.out.println("中了五個號碼!三獎!");
                break;
            case 6:
                System.out.println("中了六個號碼!頭獎!");    
                break;
            }
        }
    }
}
 

=============

3,22,23,30,33,35,
小名中了什麼獎呢?
中了五個號碼加特別號!二獎!
小王中了什麼獎呢?
中了三個號碼!五獎!
 

創作者介紹
創作者 驢子的生活日記 的頭像
驢子

驢子的生活日記

驢子 發表在 痞客邦 留言(0) 人氣( 73 )