Recursive thinking again-road strength spans multiple arrays

Source: Internet
Author: User

Kinds:

1. Sha-aa/ba/kx/wc-nyc/tyo/osa-ba/nx/cx-nyc

2. Sha-nyc/tyo/osa-nyc

The length of the distinction between/varies

The desired result 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

The first one has 36 kinds of permutations and combinations



Ideas


private void Button1_Click (object sender, EventArgs e) {string txtorg = TextBox1.Text.Trim ();            string[] T1 = txtorg.split ('-'); if (t1.            Length & 1)! = 1)//{//MessageBox.Show ("Problem with data entry");            Return            } StringBuilder sb = new StringBuilder (""); Getstringrecursive (SB, "", T1.            ToList ()); TextBox2.Text = "Advertising place for rent." To remove please pay me 5 dollars \ r \ n "+ 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 + "\ r \ n"; 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 + "\ r \ n");                    }                    else                    {                        getstringrecursive (PREBF, Retstr + '-', LISTTMP2);            }}} return retstr;        }


Copyright notice: This article Bo Master original articles, blogs, without consent may not be reproduced.

Recursive thinking again-road strength spans multiple arrays

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.