#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<math.h>
#include<dos.h>
void boundary_fill(int x,int y,int f_col,int b_col)
{
if(getpixel(x,y)!=b_col && getpixel(x,y)!=f_col)
{
putpixel(x,y,f_col);
boundary_fill(x+1,y,f_col,b_col);
boundary_fill(x-1,y,f_col,b_col);
boundary_fill(x,y+1,f_col,b_col);
boundary_fill(x,y-1,f_col,b_col);
boundary_fill(x-1,y-1,f_col,b_col);
boundary_fill(x+1,y-1,f_col,b_col);
boundary_fill(x-1,y+1,f_col,b_col);
boundary_fill(x+1,y+1,f_col,b_col);
}
}int main(){
int gm,gd=DETECT;
initgraph(&gd,&gm,"c:\\turboc3\\bgi");
rectangle(50,50,100,100);
boundary_fill(60,51,4,15);
getch();
closegraph();
return 0;
}