Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <string>
- #include <stdio.h>
- #include <Windows.h>
- using namespace std;
- int main()
- {
- HANDLE hndl = GetStdHandle(STD_OUTPUT_HANDLE);
- setlocale(0, "rus");
- ifstream fail("D:\\stroka.txt");
- SetConsoleTextAttribute(hndl, FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_INTENSITY);
- cout « "ET: ";
- const int k = 3;
- char et[k];
- for (int i = 0; i < k; i++)
- {
- if (!fail.eof())
- {
- fail » et;
- SetConsoleTextAttribute(hndl, FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY);
- cout « et;
- }
- cout « endl;
- }
- SetConsoleTextAttribute(hndl, FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_INTENSITY);
- cout « "Введите строку символов ST: ";
- const int n = 9;
- char st[n];
- for (int j = 0; j < n; j++)
- {
- cin » st[j];
- }
- cout « "ST: ";
- for (int j = 0; j < n; j++)
- {
- SetConsoleTextAttribute(hndl, FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY);
- cout « st[j];
- }
- cout « endl;
- cout « "Строка с выделенным 1 элементом" « endl;
- for (int i = 0; i < n; i++)
- {
- int r = 1;
- if ((et[0] == st[i]) && (et[r] == st[i + r]) && (et[r + 1] == st[i + r + r]))
- SetConsoleTextAttribute(hndl, FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY);
- else
- SetConsoleTextAttribute(hndl, FOREGROUND_BLUE);
- cout « st[i];
- }
- cout « endl;
- SetConsoleTextAttribute(hndl, FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_INTENSITY);
- cout « "Позиция: ";
- for (int i = 0; i < n; i++)
- if (st[i] == et[0])
- {
- int r = 1;
- while ((st[i + r] == et[r]) && (r < k))
- r++;
- if (r == k)
- {
- SetConsoleTextAttribute(hndl, FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY);
- cout « i « endl;
- break;
- }
- }
- fail.close();
- //system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement