Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <vector>
- // не забудьте подключить библиотеку <vector>
- using namespace std;
- int main() {
- vector<string>words;
- string query;
- getline(cin, query);
- string word;
- for (char c : query) {
- if (c == ' ') {
- if (!word.empty()) { //проверка на пустоту.
- words.push_back(word);
- word = ""s;
- }
- }
- else {
- word += c;
- }
- }
- if (!word.empty()) { //проверка на пустоту.
- words.push_back(word);
- }
- for (const auto& w : words) {
- cout << "[" << w << "]" << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement