提交时间:2023-12-01 13:40:34
运行 ID: 113146
#include<bits/stdc++.h> using namespace std; int res[105],cnt[105],sum; bool vis[105]; void dfs(int cur,int n){ if (cur > n){ for (int i = 1;i <= n;i++){ cout<<res[i]; } cout<<endl; sum++; return ; } for (int i = 1;i <= n;i++){ if (vis[i] == false){ vis[i] = true; res[cur] = i; dfs(cur + 1,n); vis[i] = false; } } } int main(){ int n; scanf("%d",&n); dfs(1,n); printf("%d",sum); return 0; }