Skip to content

Instantly share code, notes, and snippets.

@aakashns
Created June 22, 2012 02:00
Show Gist options
  • Save aakashns/2969768 to your computer and use it in GitHub Desktop.
Save aakashns/2969768 to your computer and use it in GitHub Desktop.
Nest Permutation
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
int n;
cin>>n;
int * A = new int[n];
for (int i = 0; i < n; i++) A[i] = i + 1;
do {
for (int i = 0; i < n; i++) cout<<A[i]<<" ";
cout<<"\n";
} while (next_permutation(A, A + n)) ;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment