Advertisement
just-killy
Nov 16th, 2023
9
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.    
  10.     cout << "[";
  11.     string word;
  12.     for (int i = 0; i < query.size(); ++i)
  13.     {
  14.         word = query[i];
  15.        
  16.         if (word != " ")
  17.         {
  18.             cout << word;
  19.         } else
  20.         {
  21.             cout << "]" << endl << "[";
  22.         }
  23.        
  24.     }
  25.     cout << "]";
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement