/* Flood fill program */
#include<iostream.h>
#include<conio.h>
#include<graphics.h>
void flood(int,int,int,int);
void main()
{
int driver=DETECT,mode;
initgraph(&driver,&mode,” “);
int x,y,i,r;
cout<<“Enter the x coordinate:\n”;
cin>>x;
cout<<“Enter the y coordinate:\n”;
cin>>y;
cout<<“size”;
cin>>r;
for(i=x-(r/2);i<=x+(r/2);i++)
{
putpixel(i,y+r/2,6);
putpixel(i,y-r/2,6);
}
for(i=y-(r/2);i<=y+(r/2);i++)
{
putpixel(x+r/2,i,1);
putpixel(x-r/2,i,1);
}
flood(x,y,2,BLACK);
getch();
closegraph();
}
void flood(int x,int y,int fillcolor,int oldcolor)
{
if(getpixel(x,y)==oldcolor)
{
setcolor(5);
putpixel(x,y,fillcolor);
flood(x+1,y,5,oldcolor);
flood(x-1,y,5,oldcolor);
flood(x,y+1,5,oldcolor);
flood(x,y-1,5,oldcolor);
}
}
- MongoDB Operators Tutorial – What are Different Operators Available? - October 5, 2019
- MongoDB Projection Tutorial : Return Specific Fields From Query - March 9, 2019
- MongoDB Index Tutorial – Create Index & MongoDB Index Types - July 6, 2018