diff --git a/1.cpp b/1.cpp index 2bade74..8afaa74 100644 --- a/1.cpp +++ b/1.cpp @@ -1,5 +1,8 @@ #include +#include +#include #include + using namespace std; int gcdDivision(int a, int b) { @@ -33,6 +36,53 @@ int z1(int a, int b, int method) { } } +void findLeastFrequentVowel(const string& filePath) { + ifstream file(filePath); + if (!file) { + cerr << "Не удалось открыть файл." << endl; + return; + } + + int counts[6] = { 0 }; // Счётчики для гласных: a, e, i, o, u, y + char vowels[] = { 'a', 'e', 'i', 'o', 'u', 'y' }; + + char ch; + while (file >> noskipws >> ch) { + ch = tolower(ch); + for (int i = 0; i < 6; ++i) { + if (ch == vowels[i]) { + ++counts[i]; + break; + } + } + } + file.close(); + + int minCount = numeric_limits::max(); + char leastVowel = '\0'; + for (int i = 0; i < 6; ++i) { + if (counts[i] > 0 && counts[i] < minCount) { + minCount = counts[i]; + leastVowel = vowels[i]; + } + } + + if (leastVowel) { + cout << "Наименее часто встречающаяся гласная: " << leastVowel + << " (" << minCount << " раз)" << endl; + } + else { + cout << "В файле нет гласных букв." << endl; + } +} + +void z3() { + string filePath; + filePath = "txt.txt"; + findLeastFrequentVowel(filePath); + +} + void z1launcher() { int a, b, method; @@ -56,6 +106,7 @@ void z1launcher() { int main() { setlocale(LC_ALL, ""); - z1launcher(); + /*z1launcher();*/ + z3(); return 0; }