首页 > 代码库 > 判断3带2以及成不成立的5张牌函数

判断3带2以及成不成立的5张牌函数

int a, b, c;

    bool x = false;

    public int mxNum;

    public int FinNum;

    int[] array = new int[10]{

        115,105,205,107,108,215,315,305,312,313

    };

    void Start()

    {

        if (array.Length % 5 == 0) {

            //排序

        for (int i = 0; i < array.Length; i++)

        {

            for (int j = i + 1; j < array.Length; j++)

            {

                if (array[j] % 100 > array[i] % 100)

                {

                    mxNum = array[j];

                    array[j] = array[i];

                    array[i] = mxNum;

                }

                if (array[j] % 100 == array[i] % 100)

                {

                    if (array[j] > array[i])

                    {

                        FinNum = array[j];

                        array[j] = array[i];

                        array[i] = FinNum;

                    }

                }

            }

        }

                //比较,寻找3个相同的

                for (int j = 0; j < array.Length - 2; j++)

                {

                    a = array[j];

                    b = array[j + 1];

                    c = array[j + 2];

                    if (a % 100 == b % 100 && a % 100 == c % 100 && b % 100 == c % 100)

                    {

                        x = true;

                        print("存在3张相同的牌,符合要求!");

                    }

                    else

                    {

                        print("没有相同的3张牌,不符合要求!!");

                    }

                }//比较for循环

           }

            else

            {

               print("牌数不是5的倍数,不符合3带1要求!");

            }

    }

判断3带2以及成不成立的5张牌函数