Generating Combinations & Permutations

Basically I would like to, out of a string, generate all permutations of all possible combinations. For example, "1234" would generate:

1, 2, 3, 4, 12, 13, 14, 21, 23, 24, 31, 32, 34, 41, 42, 43, 123, 124, 132, 134, 142, 143, 213, 214, 234, 234, 241, 243, 312, 314, 321, 324, 341, 342, 412, 413, 421, 423, 431, 432, 1234, 1243, 1324, 1342, 1423, 1432, 2134, 2143, 2314, 2341, 2413, 2431, 3124, 3142, 3214, 3241, 3412, 3421, 4123, 4132, 4213, 4231, 4312, 4321

Is there an algorithm class in C++ which would allow me to do such a thing?
I think you have something quite close but not exact fit.

http://www.cplusplus.com/reference/algorithm/next_permutation/
http://www.cplusplus.com/reference/algorithm/prev_permutation/

You may need to work out your own when you deal with 1 or 2 or 3 digit instead.
Topic archived. No new replies allowed.