anagram(next_permutation)
Posted: Thu Oct 27, 2005 11:55 am
I tried but cannot use the STL next permutation
anyone please show any example to use this?

Code: Select all
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main()
{
vector<int> a;
a.push_back(4);
a.push_back(3);
a.push_back(9);
a.push_back(6);
sort(a.begin(), a.end());
do
{
copy(a.begin(), a.end(), ostream_iterator<int>(cout, " "));
cout << endl;
} while( next_permutation(a.begin(), a.end()) );
return 0;
}