Professional Documents
Culture Documents
h>
#include<dos.h>
#include<graphics.h>
#include<conio.h>
int x_stack[10000],y_stack[10000];
int top1=-1,top2=-1;
while(flag==1)
{
if(getpixel(x,y)==bgcolor)
{
putpixel(x,y,fillcolor);
if(getpixel(x+1,y)==bgcolor)
{
push_x(x+1);
push_y(y);
}
if(getpixel(x,y+1)==bgcolor)
{
push_x(x);
push_y(y+1);
}
if(getpixel(x-1,y)==bgcolor)
{
push_x(x-1);
push_y(y);
}
if(getpixel(x,y-1)==bgcolor)
{
push_x(x);
push_y(y-1);
}
}
else
{
flag=0;
}
x=pop1();
y=pop2();
delay(2);
}
}
int main()
{
int bgcolor=0;
int fillcolor=12;
int gd=DETECT,gm;
initgraph(&gd,&gm,"C:\\TURBOC3\\BGI");
rectangle(150,150,200,200);
polyfill(170,170,bgcolor,fillcolor);
getch();
closegraph();
return 0;
}