日期:2014-05-20  浏览次数:20892 次

算法问题,高手请教C#版的 字母全排列
排列输出所有4位长的字符串,字符串为26个字母组合,同意字符串中字母可以重复.

------解决方案--------------------
IList <string> strList = new List <string> ();
for (int a = 97; a <= 122; a++)
{
char c1 = Convert.ToChar(a);
for (int b = 97; b <= 122; b++)
{
char c2 = Convert.ToChar(b);
for (int c = 97; c <= 122; c++)
{
char c3 = Convert.ToChar(c);
for (int d = 97; d <= 122; d++)
{
char c4 = Convert.ToChar(d);
string str = new string(new char[] { c1, c2, c3, c4 });
strList.Add(str);
}
}
}

}