Untitled

mail@pastecode.io avatar
unknown
plain_text
3 years ago
622 B
5
Indexable
Never
#include <iostream>
#include <string>
#include <vector>

using namespace std;

vector<string> SplitIntoWords(string text) {
    vector<string> words;
    string word;
    for (int i = 0; i < text.size(); ++i) {
        if (text[i] == ' ') {
            words.push_back(word);
            word = "";
        } else {
            word += text[i];
        }
    }
    words.push_back(word);
    
    return words;
}


int main() {
    string query;
    getline(cin, query);
    
    for (string word : SplitIntoWords(query)) {
        cout << '[' << word << ']' << endl;
    }

    return 0;
}