#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
vector<int> vectorObject;
vector<int>::iterator p;
int i;
for(i = 0; i <10; i++)
vectorObject.push_back(i);
cout << "Original ordering: ";
for(p=vectorObject.begin(); p<vectorObject.end(); p++)
cout << *p << " ";
cout << endl;
// rotate right two positions using reverse iterators
rotate(vectorObject.rbegin(), vectorObject.rbegin()+2, vectorObject.rend());
cout << "Order after two right rotates: ";
for(p=vectorObject.begin(); p<vectorObject.end(); p++)
cout << *p << " ";
cout << endl;
return 0;
}
|