Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #include <windows.h>
- int arr[10][20];
- void monitor();
- void ConsolePrint(int Y, int X, const char* str, int Colour);
- ////////////////////////////////////////////////////
- int main()
- {
- for(int i = 0; i < 19; i++)
- {
- arr[0][i] = 5;
- monitor();
- Sleep(500);
- }
- for(int i = 0; i < 9; i++)
- {
- arr[i][19] = 5;
- monitor();
- Sleep(500);
- }
- ConsolePrint(20, 0, " ", 7);
- }
- //////////////////////////////////////////////////////
- void monitor()
- {
- char sz[9];
- for(int i = 0; i < 10; i++)
- {
- for(int j = 0; j < 20; j++)
- {
- sprintf(sz, "%3d", arr[i][j]);
- if(arr[i][j] != 0) ConsolePrint(i+1, j, sz , 2);///printf("%3d", arr[i][j] );
- // else ConsolePrint(i+1, j, " ", 2);
- } // printf("\n");
- }
- }
- // ConsolePrint(2, 3, " 4", 2);
- //ConsolePrint(4, 2, "const char* str", 2);
- // ConsolePrint(2, 2, " 3", 2);
- /* какой цвет как обозначается:
- (HEX)
- 0 0 = черный
- 1 1 = синий
- 2 2 = зеленый
- 3 3 = голубой
- 4 4 = красный
- 5 5 = лиловый
- 6 6 = желтый
- 7 7 = белый
- 8 8 = серый
- 9 9 = светло-синий
- 10 a = светло-зеленый
- 11 b = светло-голубой
- 12 c = светло-красный
- 13 d = светло-лиловый
- 14 e = светло-желтый
- 15 f = ярко-белый
- */
- // Y - это строка, X - это позиция в строке
- // ============================================
- void ConsolePrint(int Y, int X, const char* str, int Colour)
- {
- DWORD result;
- COORD coord;
- HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
- SetConsoleTextAttribute(hStdout, Colour);
- coord.X = X; // Выбираем позицию
- coord.Y = Y; // Выбираем строку
- SetConsoleCursorPosition(hStdout, coord);
- WriteConsole(hStdout, str, strlen(str), &result, 0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement