Advertisement
dllbridge

Untitled

Mar 12th, 2025
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.27 KB | None | 0 0
  1.  
  2. #include    <stdio.h>
  3. #include   <string.h>
  4. #include  <windows.h>
  5.  
  6.  
  7. int  arr[10][20];
  8.  
  9.  
  10. void monitor();
  11. void ConsolePrint(int Y, int X, const char* str, int Colour);
  12.  
  13. ////////////////////////////////////////////////////
  14. int main()
  15. {
  16.     for(int i = 0; i < 19; i++)
  17.     {
  18.        arr[0][i] = 5;
  19.  
  20.        monitor();
  21.    
  22.        Sleep(500);
  23.     }
  24.  
  25.     for(int i = 0; i < 9; i++)
  26.     {
  27.        arr[i][19] = 5;
  28.        
  29.    
  30.  
  31.        monitor();
  32.    
  33.        Sleep(500);
  34.     }
  35.     ConsolePrint(20, 0, " ", 7);
  36. }
  37.  
  38.  
  39. //////////////////////////////////////////////////////
  40. void monitor()
  41. {
  42.      char sz[9];
  43.      
  44.      for(int i = 0; i < 10; i++)
  45.      {
  46.          for(int j = 0; j < 20; j++)
  47.          {
  48.                  
  49.              sprintf(sz, "%3d", arr[i][j]);    
  50.              if(arr[i][j] != 0) ConsolePrint(i+1, j, sz   , 2);///printf("%3d", arr[i][j] );    
  51.             // else               ConsolePrint(i+1, j, " ", 2);
  52.                  
  53.          }  // printf("\n");
  54.      }
  55. }
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62. //    ConsolePrint(2, 3, "  4", 2);
  63.     //ConsolePrint(4, 2, "const char* str", 2);
  64. //  ConsolePrint(2, 2, "  3", 2);
  65.  
  66.  
  67. /*                какой цвет как обозначается:
  68.    (HEX)   
  69. 0   0 = черный
  70. 1   1 = синий
  71. 2   2 = зеленый
  72. 3   3 = голубой
  73. 4   4 = красный
  74. 5   5 = лиловый
  75. 6   6 = желтый
  76. 7   7 = белый
  77. 8   8 = серый
  78. 9   9 = светло-синий
  79. 10  a = светло-зеленый
  80. 11  b = светло-голубой
  81. 12  c = светло-красный
  82. 13  d = светло-лиловый
  83. 14  e = светло-желтый
  84. 15  f = ярко-белый
  85. */
  86.  
  87. //   Y  - это строка, X - это позиция в строке
  88. //  ============================================
  89. void ConsolePrint(int Y, int X, const char* str, int Colour)
  90. {
  91.      DWORD   result;
  92.      COORD    coord;
  93.      HANDLE  hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
  94.      SetConsoleTextAttribute(hStdout, Colour);                    
  95.      coord.X = X;                                                    //  Выбираем позицию
  96.      coord.Y = Y;                                                    //  Выбираем строку
  97.      SetConsoleCursorPosition(hStdout, coord);     
  98.      
  99.      WriteConsole(hStdout, str, strlen(str), &result, 0);
  100. }
  101.  
  102.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement