iterators/rit-1.cpp - The same program using a reverse iterator. | Lecture 6 - slide 3 : 40 Program 1 |
// Reverse iterator - instead of forward iterator. #include <iostream> #include <string> #include <vector> int main(){ using namespace std; vector<double> vd; for(int i = 1; i <= 10; i++) vd.push_back(i + i/10.0); auto it1 = vd.rbegin(); while(it1 != vd.rend()){ cout << *it1 << " "; // 11 9.9 8.8 7.7 6.6 5.5 4.4 3.3 2.2 1.1 ++it1; } }