更新时间:2022-03-11 05:36:10
一个递归函数将让你通过ValidChars的所有组合运行:
A recursive function will let you run through all combinations of ValidChars:
int maxlength = 12;
string ValidChars;
private void Dive(string prefix, int level)
{
level += 1;
foreach (char c in ValidChars)
{
Console.WriteLine(prefix + c);
if (level < maxlength)
{
Dive(prefix + c, level);
}
}
}
分配一套有效的字符到ValidChars,要最大长度字符串的最大长度,然后调用潜水(,0);和远离你去。
Assign the set of valid characters to ValidChars, the maximum length of string you want to maxlength, then call Dive("", 0); and away you go.