reverse in c++ stl code example
Example 1: how to reverse a vector
//vector<int> A;
reverse(A.begin(),A.end());
Example 2: reverse() in c++
#include <iostream>
#include <algorithm>
#include <vector>
#include <iterator>
using namespace std;
int main()
{
vector<int>a = {11,22,33,44,99,55};
reverse(a.begin(), a.end());
auto it = a.begin();
for(it= a.begin(); it!=a.end(); it++){
cout << *it << ' ';
}
}
Example 3: reverse in vector c++
reverse(start_index, last_index);