文档章节

Qushun

苏子求
 苏子求
发布于 2017/06/02 08:46
字数 341
阅读 6
收藏 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();
                    }
                }
            }
        }
    }
}

 

© 著作权归作者所有

共有 人打赏支持
上一篇: C# 字符串操作
下一篇: Hu_class-CheckHu_reset
苏子求
粉丝 0
博文 9
码字总数 5416
作品 0
南京
私信 提问

暂无文章

MySQL update select 组合

组合公式如下 update tab_a a inner join tab_b b  set a.m =  b.m where a.n = b.n

皮皮猫32
19分钟前
1
0
向高手进阶,从 0 开始手写实现一个 RPC 框架!

前言 在实际后台服务开发中,比如订单服务(开发者A负责)需要调用商品服务(开发者B负责),那么开发者B会和A约定调用API,以接口的形式提供给A。通常都是B把API上传到Maven私服,然后B开始...

Java填坑路
21分钟前
2
0
漫说安全|智能的云WAF,开挂的Web防御

“漫说安全”是我们推出的一个新栏目,以简洁明了的形式展现高深晦涩的云安全。 今天我们要讲的是智能的云WAF到底有啥“本领”,答案就在漫画里^_^ 漫画看完后估计你还会有些小疑问,不要着急...

阿里云官方博客
23分钟前
0
0
数据恢复

111

ziluopao
24分钟前
0
0
记录IL2Cpp的编译过程

编者注 由于Windows 10重启,丢失部分文档,下面内容能补则补吧 需求 由于需要发布并简单处理,则使用IL2Cpp进行,编译过程和运行过程碰到很多问题,特此记录 编译过程 找不到类内部的枚举 ...

抢小孩糖吃
32分钟前
1
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部