Demonstrate reverse in vector
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
vector<int> vectorObject;
int i;
for(i = 0; i <10; i++)
vectorObject.push_back(i);
cout << "Initial: ";
for(i = 0; i <vectorObject.size(); i++)
cout << vectorObject[i] << " ";
cout << endl;
reverse(vectorObject.begin(), vectorObject.end());
cout << "Reversed: ";
for(i = 0; i <vectorObject.size(); i++)
cout << vectorObject[i] << " ";
return 0;
}
Related examples in the same category