in reply to How to convert a script from C to Perl?
void swap(char *x, char *y) { char temp; temp = *x; *x = *y; *y = temp; } void permute(char *a, int l, int r) { int i; if (l == r) printf("%s\n", a); else { for (i = l; i <= r; i++) { swap((a+l), (a+i)); permute(a, l+1, r); swap((a+l), (a+i)); //backtrack } } }
2018-03-11 Athanasius added code tags
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to convert a script from C to Perl?
by Anonymous Monk on Mar 11, 2018 at 17:22 UTC |