// http://www.cplusplus.com/reference/algorithm/next_permutation/ // next_permutation example #include #include using namespace std; int main () { int myints[] = { 1, 2, 3, 4 }; sort(myints, myints+4); cout << "The 4! possible permutations with 4 elements:\n"; do { for(auto it = begin(myints); it != end(myints); it++) cout << *it << ' '; cout << '\n'; } while( next_permutation(myints, myints+4) ); cout << "\nAfter loop:\n"; for(auto it = begin(myints); it != end(myints); it++) cout << *it << ' '; cout << '\n'; return 0; } // main()