Mega Code Archive

 
Categories / C++ Tutorial / STL Algorithms Helper
 

All permutations of ABC by use of prev_permutation()

#include <iostream> #include <vector> #include <algorithm> using namespace std; int main() {   vector<char> v;   unsigned i;   for(i=0; i<3; i++) v.push_back('A'+i);   prev_permutation(v.begin(), v.end());      do {     for(i=0; i<v.size(); i++)       cout << v[i] << endl;   } while(prev_permutation(v.begin(), v.end()));   return 0; }