I am currently trying to write a program to compute permutations of the array [0,1,2,3,4,5], I need to save all the permutations to another array and I also need the first digit, 0, to be fixed.


I have searched through quite a bit of literature on doing this, however I can't seem to be able to do it. any help is greatly appreciated. thank you in advance

So what do you need help with?

Improving your C++ knowledge to help you write the code?
Improving your google knowledge to help you find the answers with minimal effort?

You could use the next_permutation() function present in the stl for generating permutations. You search to get more info about this

Then he/she would learn nothing more than how to use iterators.

commented: That might actually be an improvement ;) +27

I would like to improve my c++ skills so that I could write the code.


also I have looked into using next_permutation() and i could use that but I would rather like to know how to code it manually.

Consider this

permute("abc")
can be broken down into

a + all results of permute("bc");
b + permute("ac");
c + permute("ab");

When you get down to permute("a"), then you stop breaking the problem down, because the answer is trivial at that point.