题目链接
AcWing 94.
代码:
#include <bits/stdc++.h>
using namespace std;
int a[11];
int main()
{
int n;
cin >> n;
for(int i=1;i<=n;i++) a[i] = i;
do{
for(int i=1;i<=n;i++)
cout << a[i] << ' ';
cout << '\n';
}while(next_permutation(a+1,a+1+n));
return 0;
}