
anagram(next_permutation)
Moderator: Board moderators
-
- Experienced poster
- Posts: 161
- Joined: Tue Oct 25, 2005 8:38 pm
- Location: buet, dhaka, bangladesh
anagram(next_permutation)
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;
}