fork download
  1. #include <vector>
  2. #include <string>
  3. #include <iostream>
  4. #include <sstream>
  5. #include <algorithm>
  6. #include <iterator>
  7. using namespace std;
  8.  
  9. int main()
  10. {
  11. vector<string> words;
  12.  
  13. string line;
  14. getline(cin, line);
  15. istringstream iss(line);
  16.  
  17. copy(istream_iterator<string>(iss), istream_iterator<string>(), back_inserter(words));
  18. copy(words.begin(), words.end(), ostream_iterator<string>(cout, "\n"));
  19. }
Success #stdin #stdout 0s 3480KB
stdin
123 456 789
stdout
123
456
789