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()]);
}
}
本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系我们删除。