The code is directly pasted
//reverse reverse_copy#include<iostream>#include<string>#include<vector>#include<algorithm>#include<functional>using namespace std;int main(){int a[]={1,2,3,4,5,6,7,8,9,10};vector<int>v(a,a+10);reverse(v.begin(),v.end());copy(v.begin(),v.end(),ostream_iterator<int>(cout," "));cout<<endl;reverse(v.begin()+1,v.end()-1);for(vector<int>::iterator itera=v.begin();itera!=v.end();++itera){cout<<*itera<<" ";}cout<<endl;reverse_copy(v.begin(),v.end(),ostream_iterator<int>(cout," "));cout<<endl;system("pause");return 0;}
// Rotate rotate_copy # include <iostream> # include <string> # include <algorithm> # include <functional> # include <vector> using namespace STD; int main () {int A [] = {1, 2, 4, 5, 6, 7, 8, 9, 10}; vector <int> V (A, A + 10); vector <int> VV (, A + 10); rotate (v. begin (), V. begin () + 3, V. end (); // It is equivalent to moving cyclically similar to the cshift (+) cshift (-) of valarray; advance (+), advance (-) for (vector <int> :: iterator iter = v. begin (); iter! = V. end (); ++ ITER) {cout <* ITER <"" ;}cout <Endl; rotate (v. begin (), find (v. begin (), V. end (), 7), V. end (); copy (v. begin (), V. end (), ostream_iterator <int> (cout, ""); cout <Endl; vector <int>: iterator Pos = vv. begin (); advance (Pos, 1); rotate_copy (vv. begin (), POs, vv. end (), ostream_iterator <int> (cout, ""); cout <Endl; Pos = vv. end (); // if no such sentence exists, an error is returned. begin () + from v. end ()-advance (Pos,-2); rotate_copy (vv. begin (), POs, vv. end (), ostream_iterator <int> (cout, ""); cout <Endl; System ("pause"); Return 0 ;}