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