• 再次递归思想-路劲跨越多个阵列


    种类:

    1.       SHA-AA/BA/KX/WC-NYC/TYO/OSA-BA/NX/CX-NYC

    2.       SHA -NYC/TYO/OSA -NYC

    /之间区分的长度不一

    想要的结果SHA-AA-NYC-BA-NYC

    SHA-AA-NYC-NX-NYC

    SHA-AA-NYC-CX-NYC

    SHA-AA-NYC-CX-NYC

    SHA-AA-TYO-BA-NYC

    SHA-AA- TYO-NX-NYC

    SHA-AA- TYO-CX-NYC

    SHA-AA- TYO-CX-NYC

    第一条有排列组合36种



    思路


    private void button1_Click(object sender, EventArgs e)
            {
                string txtOrg = textBox1.Text.Trim();
    
                string[] t1 = txtOrg.Split('-');
                //if ((t1.Length & 1) != 1)
                //{
                //    MessageBox.Show("录入数据有问题");
                //    return;
                //}
    
                StringBuilder sb = new StringBuilder("");
                GetStringRecursive(sb, "", t1.ToList());
    
                textBox2.Text = "广告位招租。欲去除请付我5元钱
    " + sb.ToString();
    
            }
    
    
            private string GetStringRecursive(StringBuilder preBf, string pre, List<string> listStr)
            {
                //List<string> listRet = new List<string>();
                string retStr = "";
                if(listStr.Count == 0)
                    return pre + "
    ";
                else{
                    List<string> listTmp = listStr[0].Split('/').ToList();
                    List<string> listTmp2 = new List<string>();
                    for (int i = 1; i <= listStr.Count - 1; i++)
                        listTmp2.Add(listStr[i]);
                    bool isOver = listTmp2.Count == 0;
    
                    for (int i = 0; i <= listTmp.Count - 1; i++)
                    {
                        string strTmp = listTmp[i].Trim();
                        //string[] = strTmp[i]
                        retStr = pre + strTmp;
                        //listStr.Remove()
                        if (isOver)
                        {
                            preBf.Append(retStr + "
    ");
                        }
                        else
                        {
                            GetStringRecursive(preBf, retStr + '-', listTmp2);
                        }
                    }
                }
    
                return retStr;
            }


    版权声明:本文博主原创文章,博客,未经同意不得转载。

  • 相关阅读:
    Java核心技术卷阅读随笔--第5章【继承】
    Java核心技术卷阅读随笔--第4章【对象与类】
    Python创建虚拟环境
    软件工程实践2017第二次作业
    tf常见的损失函数(LOSS)总结
    python-Parser使用
    论文杂记
    最近看了Light-GCN的项目,记录了一些里面用到的api
    screen笔记
    Graph Convolutional Networks for Text Classification——论文笔记
  • 原文地址:https://www.cnblogs.com/bhlsheji/p/4855366.html
Copyright © 2020-2023  润新知