Q:

Now print the elements in reverse order using ordinary iterators

0

Now print the elements in reverse order using ordinary iterators.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

#include <vector>
#include <iostream>

int main() {
  std::vector<int> vi{0, 1, 2, 3, 4, 5};
  for (auto it = --vi.end(); it + 1 != vi.begin(); --it)
    std::cout << *it << " ";
  std::cout << std::endl;

  return 0;
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now