#include <iostream>
#include <string>
#include <vector>
#include <iterator>
#include <algorithm>
#include <list>
#include <set>
#include <cstdlib>
#include <functional>
using namespace std;
template<typename T>
void printVector(vector<T> v)
{
vector<T>::iterator it;
for(it=v.begin();it!=v.end();++it) //使用迭代器输出
cout<<*it<<" ";
cout<<endl;
}
//排列算法
int main()
{
vector<int> v;
v.push_back(1);
v.push_back(2);
v.push_back(3);
printVector(v);
reverse(v.begin(),v.end());//反向输出
printVector(v);
//prev_permutation()
int A[]={2,3,4,5,6,1};
const int N=sizeof(A)/sizeof(int);
cout<<"Initially: ";
copy(A,A+N,ostream_iterator<int>(cout," "));
cout<<endl;
while(prev_permutation(A,A+N))
{
cout<<"After prev_permutation: ";
copy(A,A+N,ostream_iterator<int>(cout," "));
cout<<endl;
}
next_permutation(A,A+N);
cout<<"Ater next_permutation: ";
copy(A,A+N,ostream_iterator<int>(cout," "));
cout<<endl;
return 0;
}