public class Quanpailie {
public static void main(String[] args) {
int[] a = new int[] {1,2,3};
dfs(a, 0);
}
public static void dfs(int[] a, int m) {
int len = a.length;
if(m == len) {
for(int i : a) {
System.out.print(i + " ");
}
System.out.println();
}
for(int i=m; i<len; i++) {
swap(a, i, m);
dfs(a, m+1);
swap(a, i, m);
}
}
public static void swap(int[] a, int i, int j) {
int k = a[i];
a[i] = a[j];
a[j] = k;
}
}