void permute(string elems, int mid, int end) { static int count; if (mid == end) { cout << ++count << \" : \" << elems << end
In particular, you want std::next_permutation.
void permute(string elems, int mid, int end) { int count = 0; while(next_permutation(elems.begin()+mid, elems.end())) cout << << ++count << " : " << elems << endl; }
... or something like that...