Mega Code Archive

 
Categories / C++ Tutorial / STL Algorithms Helper
 

All permutations of ABC by use of next_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);   do {     for(i=0; i < v.size(); i++){       cout << v[i] << endl;     }   } while(next_permutation(v.begin(), v.end()));   return 0; }