给定一个字符串,输出字符串中字符的所有排列组合
public static void permutation(char[] str, int i) {
if (i >= str.length)
return;
if (i == str.length - 1) {
System.out.println(String.valueOf(str));
} else {
for (int j = i; j < str.length; j++) {
swap(str, i, j);
permutation(str, i + 1);
swap(str, i, j);
}
}
}
public void swap(char[] c, int i, int j){
temp = str[j];
str[j] = str[i];
str[i] = temp;
}