#include<graphics.h> #include<stdio.h> #include<conio.h> #include<math.h>
int main() { int x=120,y=115,bcolor,fcolor; int xmin=100,ymin=100,xmax=150,ymax=120; void floodFill4(int x,int y, int fill,int old); int gdriver = DETECT, gmode; clrscr(); clrscr(); initgraph(&gdriver, &gmode, "c:\\tc\\bgi"); rectangle(xmin, ymin, xmax, ymax); floodFill4(x,y,4,0); getch(); closegraph(); return 0; } void floodFill4(int x,int y, int fill,int old) { int current; current=getpixel(x,y); printf("%d",current); if(current == old) { setcolor(fill); putpixel(x,y,fill); floodFill4(x+1,y,4,0); floodFill4(x-1,y,4,0); floodFill4(x,y+1,4,0); floodFill4(x,y-1,4,0); } }