Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <windows.h>
- #include <string>
- #include <algorithm>
- #include <vector>
- using namespace std;
- int main()
- {
- setlocale(0, "Ukrainian");
- SetConsoleOutputCP(1251);
- SetConsoleCP(1251);
- string text{}, temp_word{};
- vector<string> all_words;
- string word;
- int i{};
- cout << "Введіть будь-який текст: " << endl;
- getline(cin, text);
- text.erase(remove_if(text.begin(), text.end(), ispunct), text.end());
- transform(text.begin(), text.end(), text.begin(), tolower);
- 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);
- sort(begin(all_words), end(all_words));
- auto iterator = unique(all_words.begin(), all_words.end());
- all_words.resize(distance(all_words.begin(), iterator));
- 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