Обновить main.cpp
This commit is contained in:
@@ -2,7 +2,8 @@
|
|||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
#include <string>
|
||||||
|
#include <sstream>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
int gcdDivision(int a, int b) {
|
int gcdDivision(int a, int b) {
|
||||||
@@ -59,7 +60,7 @@ void findLeastFrequentVowel(const string& filePath) {
|
|||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
int minCount = numeric_limits<int>::max();
|
int minCount = numeric_limits<int>::max();
|
||||||
char leastVowel = '\0';
|
char leastVowel;
|
||||||
for (int i = 0; i < 6; ++i) {
|
for (int i = 0; i < 6; ++i) {
|
||||||
if (counts[i] > 0 && counts[i] < minCount) {
|
if (counts[i] > 0 && counts[i] < minCount) {
|
||||||
minCount = counts[i];
|
minCount = counts[i];
|
||||||
@@ -76,7 +77,7 @@ void findLeastFrequentVowel(const string& filePath) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void z3() {
|
void z3_22() {
|
||||||
string filePath;
|
string filePath;
|
||||||
filePath = "txt.txt";
|
filePath = "txt.txt";
|
||||||
findLeastFrequentVowel(filePath);
|
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() {
|
int main() {
|
||||||
setlocale(LC_ALL, "");
|
setlocale(LC_ALL, "");
|
||||||
/*z1launcher();*/
|
/*z1launcher();*/
|
||||||
z3();
|
z3_16();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user