Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "pch.h"
- #include <string>
- #include <fstream>
- #include <vector>
- #include <iostream>
- using namespace std;
- bool rightWord(string a)
- {
- string glass("аеёиоуыэюяАЕЁИОУЫЭЮЯ");
- if (a.size() > 6) return false;
- bool containDigit = false;
- bool containChar = false;
- bool gl = false;
- for (int i = 0; i < a.size(); i++) {
- if (glass.find(a[i]) != string::npos) gl = true;
- if (a[i] >= 'А' && a[i] <= 'я' || a[i] == 'Ё' || a[i] == 'ё')
- containChar = true;
- else if (isdigit(a[i]))
- containDigit = true;
- else
- return false;
- }
- return containDigit && gl;
- }
- vector<string> getRightWord(string s)
- {
- vector<string> right;
- char ch;
- string a = "";
- for (int i = 0; i < s.length(); i++)
- {
- ch = s[i];
- //записываем слово, пока не встретится пробел
- if (ch != ' ' && ch != '\0' && ch != '\n') {
- a += ch;
- }
- else {
- if (rightWord(a))
- right.push_back(a);
- a = "";
- }
- }
- return right;
- }
- int main()
- {
- setlocale(LC_ALL, ".1251");
- ifstream fileIn;
- fileIn.open("input.txt");
- if (!fileIn)
- {
- cout << "Error: File not found" << endl;
- system("pause");
- return 0;
- }
- string ch;
- string a;
- cout << "Finded words: " << endl;
- while (!fileIn.eof())
- {
- string buffer;
- getline(fileIn, buffer);
- a += buffer;
- }
- fileIn.close();
- vector<string> s = getRightWord(a);
- for (int i = 0; i < s.size(); i++)
- cout << s[i] << ' ';
- fileIn.close();
- fileIn.open("input.txt");
- cout << endl << "____End of finded words___" << endl << "Original text:" << endl;
- cout << a << endl;
- cout << endl << "____End of original text___" << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement