//题目:输入一个字符串,输出字符串的全排列
//解法:确定字符串的第一个字符,然后递归求之后字符的全排列
public class Main {
public static void main(String[] args) throws Exception {
printAllSeq("abc");
}
public static void printAllSeq(String str){
if(str == null){
return;
}
char[] input = str.toCharArray();
printAllSeqHelper(input,0);
}
public static void printAllSeqHelper(char[] input, int begin){
if(begin == input.length-1){
System.out.println(input);
}else{
for(int i = begin;i<input.length;i++){
char temp = input[begin];
input[begin] = input[i];
input[i] = temp;
printAllSeqHelper(input,begin+1);
temp = input[begin];
input[begin] = input[i];
input[i] = temp;
}
}
}
}