Advertisement
Guest User

Untitled

a guest
Feb 19th, 2020
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.14 KB | None | 0 0
  1.  
  2. #include <iostream>
  3. #include <fstream>
  4. #include <string>
  5. #include <stdio.h>
  6. #include <Windows.h>
  7.  
  8. using namespace std;
  9.  
  10. int main()
  11. {
  12. HANDLE hndl = GetStdHandle(STD_OUTPUT_HANDLE);
  13. setlocale(0, "rus");
  14. ifstream fail("D:\\stroka.txt");
  15. SetConsoleTextAttribute(hndl, FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_INTENSITY);
  16. cout « "ET: ";
  17. const int k = 3;
  18. char et[k];
  19. for (int i = 0; i < k; i++)
  20. {
  21. if (!fail.eof())
  22. {
  23. fail » et;
  24. SetConsoleTextAttribute(hndl, FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY);
  25. cout « et;
  26. }
  27. cout « endl;
  28. }
  29. SetConsoleTextAttribute(hndl, FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_INTENSITY);
  30.  
  31. cout « "Введите строку символов ST: ";
  32. const int n = 9;
  33. char st[n];
  34. for (int j = 0; j < n; j++)
  35. {
  36. cin » st[j];
  37. }
  38. cout « "ST: ";
  39. for (int j = 0; j < n; j++)
  40. {
  41. SetConsoleTextAttribute(hndl, FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY);
  42. cout « st[j];
  43. }
  44. cout « endl;
  45. cout « "Строка с выделенным 1 элементом" « endl;
  46. for (int i = 0; i < n; i++)
  47. {
  48. int r = 1;
  49. if ((et[0] == st[i]) && (et[r] == st[i + r]) && (et[r + 1] == st[i + r + r]))
  50.  
  51. SetConsoleTextAttribute(hndl, FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY);
  52. else
  53. SetConsoleTextAttribute(hndl, FOREGROUND_BLUE);
  54. cout « st[i];
  55. }
  56. cout « endl;
  57.  
  58. SetConsoleTextAttribute(hndl, FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_INTENSITY);
  59. cout « "Позиция: ";
  60. for (int i = 0; i < n; i++)
  61. if (st[i] == et[0])
  62. {
  63. int r = 1;
  64. while ((st[i + r] == et[r]) && (r < k))
  65. r++;
  66. if (r == k)
  67. {
  68. SetConsoleTextAttribute(hndl, FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY);
  69. cout « i « endl;
  70. break;
  71. }
  72. }
  73. fail.close();
  74. //system("pause");
  75. return 0;
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement