Q:

Write a program to read a sequence of ints from cin and store those values in a vector

0

Write a program to read a sequence of ints from cin and store those values in a vector.

All Answers

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

#include <iostream>
#include <vector>

int main() {
  std::vector<int> iv;
  int i;
  while (std::cin >> i)
    iv.push_back(i);
  for (const auto & k : iv)
    std::cout << k << " ";
  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