#include <iostream> // std::cout
#include <algorithm> // std::next_permutation, std::sort
int main () {
int myints[] = {1,2,3};
std::sort (myints,myints+3);
std::cout << "The 3! possible permutations with 3 elements:\n";
do {
std::cout << myints[0] << ' ' << myints[1] <<' ' << myints[2] << '\n';
} while ( std::next_permutation(myints,myints+3) );
std::cout << "After loop: " << myints[0] << ' ' << myints[1] << ' ' << myints[2] << '\n';
return 0;
}
this will result
123
132
213
231
312
321
The question is
if i want to get a permutaion combination with range of N
what should i do?
if N = 2
result should be 12,13,21.....such and such
eliminate the last digit is working for 3 combination
but if its going to a bigger number it does not work
However, if your professor is asking you about combinations, is he asking for you use the STL or would he prefer you to write your own method to create combinations?