Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
5
Добавлен:
19.08.2022
Размер:
1.73 Кб
Скачать
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(){
    setlocale(LC_ALL, "rus");

    cout << "Вариант №3" << endl;
    cout << "Лабораторная работа №12" << endl;

    vector <string> array_words = {"гулко", "щука", "чашка", "ёжик", "цыпочка", "июль", "экзотично", "январь", "игрушка"};
    vector <string> hissing = {"ж", "ш", "ч", "щ"};
    string vowels_1 = "ауоиэыяюеё";
    std::string::size_type res;
    string chars;
    int words_count = 0;
    

    for (int i = 0; i < array_words.size(); i++){
        for (int j = 0; j < array_words[i].size(); j++){
            res = array_words[i].find(hissing[j]);
            if (!(res == std::string::npos)){
                chars.append(hissing[j]);
            }
        }
        words_count++;
    }
    cout << "\nШипящие буквы - встретившиеся в словах: " << chars << ";" << endl;
    cout << "Количество слов: " << words_count << ";" << endl;

    string letters;
    int vowels_counter = 0;
    int max = 0;
    string word;

    for (int i = 0; i < array_words.size(); i++){
        vowels_counter = 0;
        res = array_words[i].find_first_of(vowels_1);
        while(!(res == std::string::npos)){
            res = array_words[i].find_first_of(vowels_1, res+1);
            vowels_counter++;
        }
        if ((i == 0) || (max < vowels_counter)){
            max = vowels_counter;
            word = array_words[i];
        }
    }

    cout << "\nCлово, содержащее наибольшее количество гласных букв: " << word << endl;

    return 0;
}
Соседние файлы в папке 2 курс - Основы алгоритмизации _ вариант 3