2 solutions
-
0
简单题
#include<iostream> using namespace std; int n,a[10]; bool b[10]={0}; void dfs(int x){ if(x==n){ for(int i=0;i<n;i++){ cout<<" "<<a[i]; } cout<<endl; return; } for(int i=1;i<=n;i++){ if(!b[i]){ b[i]=true; a[x]=i; dfs(x+1); b[i]=false; a[x]=0; } } } int main(){ cin>>n; dfs(0); }
Information
- ID
- 596
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 5
- Tags
- # Submissions
- 25
- Accepted
- 13
- Uploaded By