void perm (int A[], int n, int k){if (k == n) print( A , n );else for (int i = k;i < n; i++) { swap(A[i],A[k]); perm (A,n,k+1); swap(A[i],A[k]); }}//下面有验证代码#include #include using namespace std;ofstream outfile ("out.txt");int A[100];void print ( int A[] , int n){for (int i = 1 ; i < n; i++){ cout< <<" "; outfile< <<" "; }outfile< < < n; i++) { swap(A[i],A[k]); perm (A,n,k+1); swap(A[i],A[k]); }}int main (){ for (int i = 0; i < 100; i++) A[i]=i;int n;cout<<"请输入排列数的个数:"< > n;perm (A , n+1, 1);return 0;}