Skip to content

Instantly share code, notes, and snippets.

@pinglunliao
Last active November 5, 2019 08:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pinglunliao/6c37dc05753d07e4052f to your computer and use it in GitHub Desktop.
Save pinglunliao/6c37dc05753d07e4052f to your computer and use it in GitHub Desktop.
#include <cstdio>
#include <algorithm>
using namespace std;
int main() {
int n;
while( scanf("%d", &n) != EOF ) {
int *number = new int[n];
for( int i = 0; i < n; i++ )
number[i] = n - i;
do {
for( int i = 0; i < n; i++ )
printf("%d", number[i]);
printf("\n");
} while ( std::prev_permutation(number, number + n) );
delete number;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment