提交时间:2023-11-04 09:07:02
运行 ID: 108612
#include<bits/stdc++.h> using namespace std; int n,a[1010],cnt=0; bool check[1010]={0}; int search(int m) { if(m==n+1){ cnt++; for(int i=1;i<=n;i++){ cout<<a[i]; } cout<<endl; } else{ for(int i=1;i<=n;i++){ if(!check[i]){ a[m] = i; check[i] = 1; search(m+1); check[i] = 0; } } } } int main() { //freopen("permutation.in","r",stdin); //freopen("permutation.out","w",stdout); cin>>n; search(1); //fclose(stdin); //fclose(stdout); return 0; }