题
为什么没有这个生产线的排列是否正确?对于
perm("ABC", 3)
它应该打印27点不同的排列。
private static List<string> permutated = new List<string>(30000);
public static List<string> perm(string s, int k) { return comb(s, "", k); }
private static List<string> perm(string s, string prefix, int k)
{
if (k == 0)
{
permutated.Add(prefix);
}
else
{
for (int i = 0; i < s.Length; i++)
{
perm( s.Substring( i + 1 ), prefix + s[i], k - 1 );
}
}
return permutated;
}
不隶属于 StackOverflow