Search code examples
c++permutationfactorial

C++ algorithm for N! orderings


I have a list of N items and I am wondering how I can loop through the list to get every combination. There are no doubles, so I need to get all N! orderings. Extra memory is no problem, I'm trying to think of the simplest algorithm but I'm having trouble.


Solution

  • See std::next_permutation