delix777
Apr 25th, 2023
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7.     string query;
  8.     getline(cin, query);
  9.     string word{};
  10.  
  11.     for (int i = 0; i < query.size(); ++i) {
  12.         if (query[i] == ' ') {
  13.             cout << "["s << word << "]"s << endl;
  14.             word = ""s;
  15.         }else{
  16.             word += query[i];
  17.         }
  18.     }
  19.     cout << "["s << word << "]"s << endl;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment