1 solutions
-
2
#include<bits/stdc++.h> using namespace std; int n; char a[15]; bool is(string n,char m){ for(int i=0;i<n.size();i++) if(n[i]==m) return false; return true; } void A(string w){ if(w.size()==n){ for(int i=0;i<n;i++) cout<<w[i]<<" ";cout<<"\n";} else for(int i=0;i<n;i++) if(is(w,a[i])) A(w+a[i]); } int main(){ cin>>n; for(int i=0;i<n;i++) a[i]=i+1+'0'; A(""); return 0; }
这道题貌似还没有测试数据?
- 1
Information
- ID
- 265
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 10
- Tags
- # Submissions
- 7
- Accepted
- 2
- Uploaded By