Обновить 1.cpp
This commit is contained in:
53
1.cpp
53
1.cpp
@@ -1,5 +1,8 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <fstream>
|
||||||
|
#include <cctype>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
int gcdDivision(int a, int b) {
|
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<int>::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() {
|
void z1launcher() {
|
||||||
int a, b, method;
|
int a, b, method;
|
||||||
|
|
||||||
@@ -56,6 +106,7 @@ void z1launcher() {
|
|||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
setlocale(LC_ALL, "");
|
setlocale(LC_ALL, "");
|
||||||
z1launcher();
|
/*z1launcher();*/
|
||||||
|
z3();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user