fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <string>
  4. #include <iterator>
  5. #include <algorithm>
  6.  
  7. using namespace std;
  8.  
  9. int main()
  10. {
  11. vector<string> words;
  12. copy(istream_iterator<string>(cin), istream_iterator<string>(), back_inserter(words));
  13.  
  14. for (int i = 0; i < words.size(); ++i)
  15. cout << (i+1) << ": " << words[i] << endl;
  16.  
  17. return 0;
  18. }
Success #stdin #stdout 0.02s 2864KB
stdin
I am King
stdout
1: I
2: am
3: King