Qushun
Qushun
苏子求 发表于8个月前
Qushun
  • 发表于 8个月前
  • 阅读 0
  • 收藏 0
  • 点赞 0
  • 评论 0

【腾讯云】如何购买服务器最划算?>>>   

摘要: 可以给出测试胡牌组合的编码

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Collections;

namespace QuShun
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        public int xxxnum = 0;
        public int hutestnum = 1;

        List<int> Pailist = new List<int>();

        private void button1_Click(object sender, EventArgs e)
        {
            Pailist.Add(51);
            Pailist.Add(52);
            Pailist.Add(52);
            Pailist.Add(52);
            Pailist.Add(53);
            Pailist.Add(54);
            Pailist.Add(55);
            Pailist.Add(55);
            Pailist.Add(56);
            Pailist.Add(57);
            Pailist.Add(57);
            Pailist.Add(58);
            Pailist.Add(58);
            Pailist.Add(59);

            label1.Text += Pailist.Count.ToString() + ":";
            for (int i = 0; i < Pailist.Count; i++)
            {
                label1.Text += Pailist[i] + ",";
            }
            hutestnum = 1;
            QuShun(Pailist, xxxnum);
        }

        void QuShun(List<int> _pailist, int xnum)
        {
            _pailist.Sort();
            List<int> Tlist = new List<int>(_pailist.ToArray());
            List<int> Vlist = new List<int>(_pailist.ToArray());
            //_pailist.ForEach(lx => Vlist.Add(lx));


            for (int i = 0; i < Vlist.Count; i++)
            {
                for (int j = i + 1; j < Vlist.Count; j++)
                {
                    if (Vlist[i].Equals(Vlist[j]))
                    {
                        Vlist.RemoveAt(j);
                        if (i > 0)
                        {
                            i--;
                        }
                    }
                }
            }
            bool isfound = false;
            string tt = "";
            //  tt += Tlist.Count.ToString() + ":   ";
            tt += hutestnum.ToString() + ":   ";
            for (int ii = 0; ii < Tlist.Count; ii++)
            {
                tt += Tlist[ii] + ",";
            }
            listBox2.Items.Add(tt);

            for (int i = 0; i < Vlist.Count; i++)
            {
                int TT1 = (int)Vlist[i];
                int TT2 = (int)Vlist[i] + 1;
                int TT3 = (int)Vlist[i] + 2;
                if ((Tlist.Contains(TT2) && Tlist.Contains(TT3)) || Tlist.Count(x => x == TT1) > 2)
                {
                    isfound = true;
                }
            }
            if (isfound == false)
            {
                tt = "";
                //  tt += Tlist.Count.ToString() + ":   ";
                for (int ii = 0; ii < Tlist.Count; ii++)
                {
                    tt += Tlist[ii] + ",";
                }
                //  listBox3.Items.Add(tt);
                listBox3.Items.Add(hutestnum.ToString() + ":" + tt);
                xxxnum = 0;
                hutestnum++;
                //return;
            }
            else
            {
                xxxnum++;
                for (int i = 0; i < Vlist.Count; i++)
                {
                    int TT1 = (int)Vlist[i];
                    int TT2 = (int)Vlist[i] + 1;
                    int TT3 = (int)Vlist[i] + 2;

                    if ((Tlist.Contains(TT2) && Tlist.Contains(TT3)))
                    {
                        Tlist.Remove(TT1); Tlist.Remove(TT2); Tlist.Remove(TT3);
                        listBox1.Items.Add(hutestnum.ToString() + ":" + xxxnum.ToString() + "#   " + TT1.ToString() + "," + TT2.ToString() + "," + TT3.ToString() + "|");
                        QuShun(Tlist, xxxnum);
                        Tlist.Add(TT1); Tlist.Add(TT2); Tlist.Add(TT3);
                        Tlist.Sort();
                    }
                    else if (Tlist.Count(x => x == TT1) > 2)
                    {
                        Tlist.Remove(TT1); Tlist.Remove(TT1); Tlist.Remove(TT1);
                        listBox1.Items.Add(hutestnum.ToString() + ":" + xxxnum.ToString() + "#   " + TT1.ToString() + "," + TT1.ToString() + "," + TT1.ToString() + "|");
                        QuShun(Tlist, xxxnum);
                        Tlist.Add(TT1); Tlist.Add(TT2); Tlist.Add(TT3);
                        Tlist.Sort();
                    }
                }
            }
        }
    }
}

 

共有 人打赏支持
粉丝 0
博文 9
码字总数 5416
×
苏子求
如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
* 金额(元)
¥1 ¥5 ¥10 ¥20 其他金额
打赏人
留言
* 支付类型
微信扫码支付
打赏金额:
已支付成功
打赏金额: