#include <graphics.h>
#include <conio.h>
#include <time.h>
void main(){
initgraph(800, 600);
srand(time(NULL));
setbkcolor(WHITE);
cleardevice();
setcolor(BLACK);
for (int x = 200; x <=600; x += 40){
line(x,0,x,400);
}
for (int y = 0; y <=400; y += 40){
line(200, y, 600, y);
}
for (int x = 200; x < 600; x += 50){
setfillcolor(RGB(rand()%256, rand()%256, rand()%256));
fillrectangle(x,500,x+50,600);
while (true)
{
m = GetMouseMsg();
if (m.uMsg == WM_LBUTTONDOWN)
if (m.x >= 200 && m.x < 600 && m.y >= 500 && m.y <= 600)
setfillcolor(getpixel(m.x, m.y));
else if(m.x>=200&&m.x<=600&&m.y>=0&&m.y<=400)
floodfill(m.x, m.y, BLACK);
if (m.uMsg == WM_RBUTTONDOWN)
return;
}
_getch();
closegraph();
}
#include <conio.h>
#include <time.h>
void main(){
initgraph(800, 600);
srand(time(NULL));
setbkcolor(WHITE);
cleardevice();
setcolor(BLACK);
for (int x = 200; x <=600; x += 40){
line(x,0,x,400);
}
for (int y = 0; y <=400; y += 40){
line(200, y, 600, y);
}
for (int x = 200; x < 600; x += 50){
setfillcolor(RGB(rand()%256, rand()%256, rand()%256));
fillrectangle(x,500,x+50,600);
}
setfillcolor(BLACK);
while (true)
{
m = GetMouseMsg();
if (m.uMsg == WM_LBUTTONDOWN)
if (m.x >= 200 && m.x < 600 && m.y >= 500 && m.y <= 600)
setfillcolor(getpixel(m.x, m.y));
else if(m.x>=200&&m.x<=600&&m.y>=0&&m.y<=400)
floodfill(m.x, m.y, BLACK);
if (m.uMsg == WM_RBUTTONDOWN)
return;
}
_getch();
closegraph();
}