码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2016-11-16 20:13:32      阅读:213      评论:0      收藏:0      [点我收藏+]

标签:int   start   ++   排序   else   bool   new   函数   als   

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张牌函数

标签:int   start   ++   排序   else   bool   new   函数   als   

原文地址:http://www.cnblogs.com/wanggang550/p/6071056.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!