文档章节

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();
                    }
                }
            }
        }
    }
}

 

© 著作权归作者所有

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

暂无文章

用any-loader封装jQuery的XHR —— 随便写着玩系列

哎,都说没人用JQuery啦,叫你别写这个。 其实我也是好高骛远使用过npm上某个和某个很出名的XHR库,嗯,认识我的人都知道我喜欢喷JQ,以前天天喷,见面第一句,你还用JQ,赶紧丢了吧。但我也...

曾建凯
今天
4
0
聊聊storm的AggregateProcessor的execute及finishBatch方法

序 本文主要研究一下storm的AggregateProcessor的execute及finishBatch方法 实例 TridentTopology topology = new TridentTopology(); topology.newStream("spout1", spout......

go4it
今天
3
0
大数据教程(7.5)hadoop中内置rpc框架的使用教程

博主上一篇博客分享了hadoop客户端java API的使用,本章节带领小伙伴们一起来体验下hadoop的内置rpc框架。首先,由于hadoop的内置rpc框架的设计目的是为了内部的组件提供rpc访问的功能,并不...

em_aaron
今天
5
0
CentOS7+git+github创建Python开发环境

1.准备CentOS7 (1)下载VMware Workstation https://pan.baidu.com/s/1miFU8mk (2)下载CentOS7镜像 https://mirrors.aliyun.com/centos/ (3)安装CentOS7系统 http://blog.51cto.com/fengyuns......

枫叶云
昨天
3
0
利用ibeetl 实现selectpicker 的三级联动

1. js 直接写在html页面上面,ibeetl 就可以动态地利用后台传上来的model List ,不需要每次点击都要ajax请求后台 2. 使用selectpicker 的时候,除了对selecct option的动态处理后,还需要 $("#...

donald121
昨天
5
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部