Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

Богачова Катерина КА-35

Завдання 7 Б

Реалізація програми:
#include <iostream>
#include <windows.h>
#include <cstdlib>
#include <ctime>

using namespace std;

int main() {
srand(time(0));

HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);

CONSOLE_SCREEN_BUFFER_INFO consoleInfo;
GetConsoleScreenBufferInfo(hConsole, &consoleInfo);
WORD defaultColor = consoleInfo.wAttributes;

for (int i = 0; i < 10; ++i) {


int textColor = rand() % 15 + 1;

int positionX = rand() % 80;


int positionY = rand() % 25;

SetConsoleTextAttribute(hConsole, textColor);
COORD pos = { positionX, positionY };
SetConsoleCursorPosition(hConsole, pos);

cout << "Hello, World!" << endl;

Sleep(1000);
}

SetConsoleTextAttribute(hConsole, defaultColor);

return 0;
}
Робота програми:

You might also like