fork download
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <iterator>
  4. #include <vector>
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10. std::vector<int> a;
  11.  
  12. cout << "Enter a sequence of numbers: ";
  13.  
  14. std::copy(std::istream_iterator<int>(cin),
  15. std::istream_iterator<int>(),
  16. std::back_inserter(a));
  17.  
  18. cout << "You've entered: ";
  19. for (auto& num : a)
  20. {
  21. cout << num << " ";
  22. }
  23. cout << endl;
  24.  
  25. return 0;
  26. }
  27.  
Success #stdin #stdout 0s 3464KB
stdin
1 2 3
stdout
Enter a sequence of numbers: You've entered: 1 2 3