public class 全排列 {
public static void main(String[] args) {
char[] s = {'a','b','c'};
int to = s.length - 1;
int from = 0;
permutation(s, from, to);
}
public static void permutation(char[] s, int from, int to){
if(to <= 1)
return;
if(from == to)
System.out.println(s);
else{
for (int i = from; i <= to; i++) {
swap(s, from, i);
permutation(s, from + 1, to);
swap(s, i, from);
}
}
}
public static void swap(char[] s, int i, int j){
char temp = s[i];
s[i] = s[j];
s[j] = temp;
}
}