提交时间:2023-11-04 09:09:00
运行 ID: 108631
#include<bits/stdc++.h> using namespace std; int n,a[100],use[100]; int cnt =0; void out(){ int i; for(i=1;i <=n;i++) printf("%d",use[i]); cnt++; cout<<endl; } void dfs(int k){ int i; if(k==n){ out(); return; } for(i=1;i<=n;i++){ if(!a[i]){ a[i]=1; use[k+1]=i; dfs(k+1); a[i]=0; } } } int main(){ //freopen("permutation.in","r",stdin); //freopen("permutation.out","w",stdout); cin>>n; dfs(0); cout<<cnt; return 0; }