如果我理解正确,则会为您提供一组字符
c和所需的长度
n。
从技术上讲,没有重复的排列。我假设您想要所有长度
n为的字符串,且包含的字母
c。
您可以这样进行:
to generate all strings of length N with letters from C -generate all strings of length N with letters from C that start with the empty string.to generate all strings of length N with letters from C that start with a string S -if the length of S is N -print S -else for each c in C -generate all strings of length N with letters from C that start with S+c
在代码中:
printAll(char[] c, int n, String start){ if(start.length >= n){ System.out.println(start) }else{ for(char x in c){ // not a valid syntax in Java printAll(c, n, start+x); } }}


