Mega Code Archive

 
Categories / C++ Tutorial / STL Algorithms Modifying Sequence Operations
 

Reverse a stack of integers

#include <iostream> #include <vector> #include <algorithm> using namespace std;     int main() {   vector<int> v;   unsigned int i;       for(i=0; i<10; i++) v.push_back(i);       cout << "Initial: ";   for(i=0; i<v.size(); i++)       cout << v[i] << endl;       reverse(v.begin(), v.end());       for(i=0; i<v.size(); i++)      cout << v[i] << endl;       return 0; }