Permutations: Difference between revisions

Content added Content deleted
Line 1,066: Line 1,066:
Full non-recursive algorithm generating permutation in reversed lexicographical order. Taken from here: [https://habrahabr.ru/post/310574/]. It's a little bit modified algorythm of Narayana Pandit [3]. It reveres a string and works until a and b are not equal. It searches a new permutation directly (first internal cycle) as we do it on a sheet of paper. You can use English alphabet instead of digits. Run it from console with a parametr like "program.o 12345" or "program.o abcd":
Full non-recursive algorithm generating permutation in reversed lexicographical order. Taken from here: [https://habrahabr.ru/post/310574/]. It's a little bit modified algorythm of Narayana Pandit [3]. It reveres a string and works until a and b are not equal. It searches a new permutation directly (first internal cycle) as we do it on a sheet of paper. You can use English alphabet instead of digits. Run it from console with a parametr like "program.o 12345" or "program.o abcd":
<lang c>
<lang c>

//Author Ivan Gavryushin @dcc0
#include <stdio.h>
#include <stdio.h>
#include <string.h>
#include <string.h>