Обновить main.cpp

This commit is contained in:
oltnd
2024-11-22 23:12:57 +03:00
parent 82dab1bb95
commit 4c4a5b2693

View File

@@ -2,7 +2,8 @@
#include <fstream>
#include <cctype>
#include <limits>
#include <string>
#include <sstream>
using namespace std;
int gcdDivision(int a, int b) {
@@ -59,7 +60,7 @@ void findLeastFrequentVowel(const string& filePath) {
file.close();
int minCount = numeric_limits<int>::max();
char leastVowel = '\0';
char leastVowel;
for (int i = 0; i < 6; ++i) {
if (counts[i] > 0 && counts[i] < minCount) {
minCount = counts[i];
@@ -76,7 +77,7 @@ void findLeastFrequentVowel(const string& filePath) {
}
}
void z3() {
void z3_22() {
string filePath;
filePath = "txt.txt";
findLeastFrequentVowel(filePath);
@@ -104,9 +105,51 @@ void z1launcher() {
}
}
void findWordCombination(const string& fileName, const string& combination) {
ifstream file(fileName);
if (!file.is_open()) {
cerr << "Не удалось открыть файл: " << fileName << endl;
return;
}
string line;
size_t lineNumber = 0;
bool found = false;
while (getline(file, line)) {
++lineNumber;
// Проверяем, содержит ли строка указанное сочетание слов
if (line.find(combination) != string::npos) {
found = true;
cout << "Найдено в строке " << lineNumber << ": " << line << endl;
}
}
if (!found) {
cout << "Сочетание \"" << combination << "\" не найдено в файле." << endl;
}
file.close();
}
void z3_16() {
string fileName, combination;
fileName = "txt2.txt";
cout << "Введите сочетание слов для поиска: ";
cin >> combination;
findWordCombination(fileName, combination);
}
int main() {
setlocale(LC_ALL, "");
/*z1launcher();*/
z3();
z3_16();
return 0;
}