踢节
2023-07-26 16:53:22
发布于:广东
7阅读
0回复
0点赞
#include <iostream>
using namespace std;
const int maxn = 1e6+7;
int n,p[maxn];
bool used[maxn];/*🎂🤳🐱👤🐱🏍*/
void dfs(int idx)
{
if (idx == n+1)
{
for (int i = 1; i <= n; i++)
{
cout << p[i] << " ";
}
cout << "\n";
return ;
}
for (int i = 1; i <= n; i++)
{
if (!used[i])
{
p[idx] = i;
used[i] = true;
dfs(idx + 1);
used[i] = false;
/*φ(* ̄0 ̄) */ p[idx] = 0;
}
}
}
int main()
{
cin >> n;
dfs(1);
return 0;
}
这里空空如也
有帮助,赞一个