Q:

Given a vector that has ten elements, copy the elements from positions 3 through 7 in reverse order to a list

0

Given a vector that has ten elements, copy the elements from positions 3 through 7 in reverse order to a list.

All Answers

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

#include <vector>
#include <list>
#include <iostream>

int main() {
  std::vector<int> vi{0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
  std::list<int> li(vi.rbegin() + 2, vi.rend() - 3);
  for (const auto &i : li)
    std::cout << i << " ";

  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