Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <ctime>
- #include <Windows.h>
- using namespace std;
- void SetColor(int text, int background) // функция для изменения цветов фона и симфолов
- {
- HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
- SetConsoleTextAttribute(hStdOut, (WORD)((background << 4) | text));
- }
- string CreateWords(int step)
- {
- string word;
- srand(time(NULL) + step);
- int word_lenght = rand() % 6 + 2; // случайная длина каждого слова
- for (int letter = 0; letter < word_lenght; letter++) // создаём слово
- {
- srand(time(NULL)+letter);
- int word_letter = rand() % 26 + 65;
- word = word + char(word_letter);
- Sleep(1); // Для увеличения разнообразия слов
- }
- return word;
- }
- void main()
- {
- const int M = 20, N = 10; // кол-во строк, кол-во столбцов (M = 20, N = 10)
- const int K = 2, L = 7; // мин. кол-во букв в слове, мак. кол-во букв в слове (K = 2, L = 7)
- int count_mark_words = 0; // счётчик количества помеченных слов
- string arr[M][N]; // задаём массив
- int step_0 = 0;
- for (int row = 0; row < M; row++) // заполение словами
- {
- for (int col = 0; col < N; col++)
- {
- arr[row][col] = CreateWords(step_0);
- step_0++;
- }
- }
- for (int row = 0; row < M; row++)
- {
- int count_letter_for_mark = 0;
- for (int j = 0; j < N; j++) // проверка количества букв в строке на кратность трём
- {
- count_letter_for_mark += arr[row][j].size();
- }
- if (count_letter_for_mark % 3 == 0)
- {
- for (int col = 0; col < N; col++)
- {
- SetColor(2, 0);
- cout << arr[row][col]<<'\t';
- }
- SetColor(15, 0);
- cout << endl;
- count_mark_words += N;
- }
- else
- {
- for (int col = 0; col < N; col++) // вывод слов, если количество букв строки не кратно трём
- {
- i < letter_count; i++)
- {
- if ((int(word_1[i]) = string word_1 = arr[row][col];
- int letter_count = arr[row][col].size();
- int vowel_count = 0;
- for (int i = 0; = 65) or (int(word_1[i]) == 69) or (int(word_1[i]) == 73) or (int(word_1[i]) == 79) or (int(word_1[i]) == 85) or (int(word_1[i]) == 89))
- {
- vowel_count++;
- }
- }
- if ((vowel_count * 5) <= (letter_count - vowel_count)) // проверка на отношение гласных и согласных
- {
- SetColor(2, 0);
- cout << arr[row][col] << '\t';
- SetColor(15, 0);
- count_mark_words++;
- }
- else
- {
- SetColor(15, 0);
- cout << arr[row][col] << '\t';
- }
- }
- cout << endl;
- }
- }
- setlocale(LC_ALL, "RUS");
- cout << "Количество выделенных слов = " << count_mark_words << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement