枚举排列组合
枚举排列
public class Main {
public static void print_permutation(int n,int []A,int cur){
if(cur==n){
for(int i=0;i<n;i++)
System.out.print(A[i]);
System.out.println();
}
else
for(int i=1;i<=n;i++){
int ok=1;
for(int j=0;j<cur;j++)
if(A[j]==i) ok=0;
if(ok>0){
A[cur] =i;
print_permutation(n, A, cur+1);
}
}
}
public static void main(String[] args) {
int A[] = new int[5]; ;
Main.print_permutation(5, A, 0);
}
}