I want to print all permutation of string in lexicographic order. I wrote this code:
void permute(char *a, int i, int n) {
if (i == (n-1)) printf(\"\\\"%s
This is voluntarily an answer that does not answer this question.
This other question was marked as a duplicate to this one. This answer would be acceptable for the other question even if it is non sense here.
This could be a simple recursive C implementation to get all permutations in lexicographic order. It is not optimized but easy to understand and to implement:
Concrete implementation:
#include
#define SIZE 4
void disp(int *fullarr, int n, int * begin, int pos) {
int i, j;
int found;
if (pos == n) {
for(i=0; i< n; i++) {
printf("%2d", begin[i]);
}
printf("\n");
return;
}
for (i=0; i