//#pragma warning(disable:4996)
#include<iostream>
#define maxn 100
using namespace std;
int ans[maxn];
bool vis[maxn];
int n;
void dfs(int x)
{
if (x > n)
{
for (int i = 1; i <= n; i++)
cout << ans[i] << " ";
cout << "\n";
return;
}
else
{
for (int i = 1; i <= n; i++)
{
if (!vis[i])
{
vis[i] = 1;
ans[x] = i;
dfs(x + 1);
vis[i] = 0;
}
}
}
}
int main()
{
cin >> n;
dfs(1);
return 0;
}
相关文章
- 03-092020-12-24
- 03-092020-12-24
- 03-092020-12-24
- 03-092020-12-24
- 03-092020-12-24 LeetCode每日一题candy左右遍历求解相邻问题