Advertisement
chevengur

Вводный курс: основы C++ | Урок 6: Цикл for 4/4

Aug 22nd, 2023 (edited)
100
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 1 0
  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 = ""s;
  10.     char space = ' ';
  11.     for (int i = 0; i < query.size(); ++i) {
  12.  
  13.         if (query[i] != space) {
  14.             word += query[i];
  15.         }
  16.         else {
  17.             std::cout << "[" << word << "]" << endl;
  18.             word = ""s;
  19.         }
  20.  
  21.     }
  22.     std::cout << "[" << word << "]";
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement