Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- vector<int> T;
- vector<bool> visit;
- void permu(int n, int j){
- if(j==n){
- cout<<'(';
- for(int i=0;i<n-1;++i) cout<<T[i]<<',';
- cout<<T[n-1]<<')'<<endl;
- }
- else{
- for(int i=0; i<n; ++i){
- if(!visit[i]){
- visit[i]=true;
- T[j]=i+1;
- permu(n,j+1);
- visit[i]=false;
- }
- }
- }
- }
- int main(){
- int n;
- cin>>n;
- T = vector<int> (n);
- visit = vector<bool> (n,false);
- permu(n,0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement