rev_iter.CPP
Upload User: dq031136
Upload Date: 2022-08-08
Package Size: 802k
Code Size: 1k
Development Platform:

C++ Builder

  1. #ifdef __BCPLUSPLUS__
  2. #include <deque.h>
  3. #else
  4. #include <deque>
  5. #endif
  6. #include <iostream.h>
  7. using namespace std;
  8. typedef deque<int> INTDEQUE;
  9. void main(void)
  10.  {
  11.    // Create A and fill it with elements 1,2,3,4 and 5 using push_back function
  12.    INTDEQUE A;
  13.    A.push_back(1);
  14.    A.push_back(2);
  15.    A.push_back(3);
  16.    A.push_back(4);
  17.    A.push_back(5);
  18.    // Now print the contents in reverse order using reverse_iterator
  19.    // and functions rbegin() and rend()
  20.    INTDEQUE::reverse_iterator rpi;
  21.    for(rpi = A.rbegin(); rpi != A.rend(); rpi++)
  22.       cout << *rpi << " ";
  23.    cout<< endl;
  24.  }