日期:2014-05-18 浏览次数:20852 次
for(int i=1;i<=9;i++) for(int j=i+1;j<=9;j++) Console.WriteLine("{0},{1}",i,j);
------解决方案--------------------
public static List<string> P(string s) { if (s.Length==1) { List<string> r = new List<string>(); r.Add(""); r.Add("a"); return r; } else { List<string> tmp = P(s.Substring(0, s.Length - 1)); List<string> ret=new List<string>(); foreach (string t in tmp) { ret.Add(t); } foreach (string t in tmp) { for (int len = t.Length; len >=0; len--) { string insert = t; insert=insert.Insert(len, s[s.Length - 1].ToString()); ret.Add(insert); } } return ret; } } List<string> ret = P("abcdefghij"); Dictionary<int, string> dic = new Dictionary<int, string>(); foreach (string s in ret) { try { dic.Add(s.GetHashCode(), s); } catch { MessageBox.Show(s + "_" + dic[s.GetHashCode()]); } }