Advertisement
Uncleeee

разбить строку на слова

Jan 28th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. #include <iostream>
  2. #include <sstream>
  3. #include <string>
  4. #include <vector>
  5. using namespace std;
  6.  
  7. int main() {
  8. cout << "Enter the string: ";
  9. string str;
  10. getline(cin, str);
  11.  
  12. vector <string> vecstr;
  13. string word;
  14. stringstream s(str);
  15.  
  16. while (s >> word) vecstr.push_back(word);
  17.  
  18. int vsize = vecstr.size();
  19. for (int i = 0; i < vsize; i++)
  20. cout << vecstr[i] << endl;
  21.  
  22. cin.get();
  23. return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement