#include<graphics.h>
#include<stdio.h>
#include<conio.h>
void flood(int x, int y, int new_col, int old_col)
{
if (getpixel(x, y) == old_col) {
putpixel(x, y, new_col);
flood(x + 1, y, new_col, old_col);
flood(x - 1, y, new_col, old_col);
flood(x, y + 1, new_col, old_col);
flood(x, y - 1, new_col, old_col);
flood(x + 1, y+1, new_col, old_col);
flood(x - 1, y+1, new_col, old_col);
flood(x+1, y + 1, new_col, old_col);
flood(x+1, y - 1, new_col, old_col);
}
}
int main()
{
int gd=DETECT, gm;
initgraph(&gd, &gm,"C:\\TURBOC3\\BGI");
rectangle(50, 50, 100, 100);
flood(51, 51, 12, 0);
getch();
closegraph();
return 0;
}