提交时间:2023-11-04 09:08:19
运行 ID: 108627
#include<bits/stdc++.h> #include<cstdio> using namespace std; int k,a[100],m; bool b[100]; int print() { for(int e=1;e<=m;e++) cout<<a[e]; cout<<endl; k++; return 0; } int dfs(int c) { if(c>m) { print(); return 0; } else { for(int d=1;d<=m;d++) if(b[d]==0) { a[c]=d; b[d]=1; dfs(c+1); a[c]=0; b[d]=0; } } } int main() { //freopen("permutation.in","r",stdin); //freopen("permutation.out","w",stdout); cin>>m; dfs(1); cout<<k; }