文档章节

Qushun

苏子求
 苏子求
发布于 2017/06/02 08:46
字数 341
阅读 3
收藏 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
作品 0
南京

暂无文章

71.告警系统主脚本 配置文件 监控项目

20.20 告警系统主脚本(main.sh) 20.21 告警系统配置文件 20.22 告警系统监控项目 20.20 告警系统主脚本(main.sh): ~1.约定:把以后所有的shell脚本放在/usr/local/sbin下,也方便我们查...

王鑫linux
12分钟前
0
0
装饰者模式

装饰者模式 Q:何为装饰模式? ()地给一个对象添加一些额外的(),并且()时,并不影响原对象。扩展功能来说,装饰器模式相比生成子类更为灵活。 Q:使用场景? 1.想要在不影响其他对象的情况下...

阿元
32分钟前
0
0
GO 切片(slice)相关语法

package mainimport("fmt")func main() {var intArr [5]int = [...]int{1,2,3,4,5} //定义一个数组slice := intArr[2:4] //第二个(包含)下标到第四个下标(不包含)fmt.Println...

汤汤圆圆
34分钟前
0
0
活动招募 HUAWEI HiAI公开课·北京站-如何在4小时把你的APP变身AI应用

人工智能和机器学习是全球关注的新趋势,也是当前最火爆、最流行的话题。当你拿手机用语音助手帮你点外卖,智能推荐帮你把周边美食一网打尽;当你拿起P20拍照时,它将自动识别场景进行最美优...

华为终端开放实验室
48分钟前
1
0
匹配两位小数,js正则

var regex = /^\d*(\.[1-9]|\.\d[1-9])*$/ console.log(1.2,regex.test(1.2)); console.log(0.3,regex.test(0.3)); console.log(1.03,regex.test(1.03)); ......

微信小程序-暗潮
53分钟前
1
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部