Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <windows.h>
- #include <string>
- #include <vector>
- using namespace std;
- int main()
- {
- SetConsoleOutputCP(1251);
- SetConsoleCP(1251);
- string text{}, temp_word{};
- vector<string> all_words;
- string word;
- int i{};
- cout << "Введіть будь-який текст: " << endl;
- getline(cin, text);
- for (i = 0; i < text.size(); i++) {
- if (text[i] != ' ') {
- word += text[i];
- }
- else {
- all_words.push_back(word);
- word = "";
- }
- }
- all_words.push_back(word);
- cout << "Список слів в наведеному тексті: " << endl;
- for (i = 0; i < all_words.size(); i++) {
- if (all_words[i] != "") {
- cout << all_words[i] << endl;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement