提交时间:2023-11-04 09:09:27
运行 ID: 108640
#include<bits/stdc++.h> using namespace std; int n; int a[10001] = {0} , b[10001] = {0} , sum = 0; int print(); int search(int k) { int i; for(i = 1 ; i <= n ; i++){ if(!b[i]){ a[k] = i; b[i] = 1; if(k == n) print(); else search(k+1); b[i] = 0; } } } int main() { cin>>n; search(1); cout<<sum<<endl; return 0; } int print() { sum++; for(int i=1;i<=n;i++) cout<<a[i]; cout<<endl; }