Advertisement
Jambix64

VectorReverse_iteratorUpdate4

Sep 4th, 2016
455
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.59 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <vector>
  4. #include <algorithm>
  5. using namespace std;
  6.  
  7. int main(){
  8.        vector <int> numbers;
  9.  
  10.        for (int i = 1; i <= 10; i++)
  11.        numbers.push_back(i);
  12.  
  13.         // conta todos os elementos do vector
  14.         for (vector<int>::iterator it = numbers.begin(); it != numbers.end(); it++) {
  15.             cout << *it << endl;
  16.         }
  17.  
  18.         cout <<"\n"<< endl;
  19.         // reverse conta de traz para frente
  20.         for (vector<int>::reverse_iterator itreverse = numbers.rbegin(); itreverse != numbers.rend(); itreverse++) {
  21.  
  22.             cout << *itreverse << endl;
  23.  
  24.         }
  25.  
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement