Tuesday 23 February 2016

Implementation of Flood fill algorithm

Q) Implementation of Flood Fill Algorithm.
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
void floodfill(int x,int y)
    { 
int a =getpixel(x,y);
    setcolor(3);
    if(a==0)
{
    putpixel(x,y,3);
     floodill(x+1,y);
     floodfill(x-1,y);
    floodfill(x,y+1);
     floodfill(x,y-1);
    }
    }

int main()
{

   int gdriver = DETECT, gmode;
   initgraph(&gdriver, &gmode, "C:\\TC\\bgi");
   setcolor(2);
   circle(250, 250, 50);
   bounfill(250,250);
   getch();
   closegraph();
   return 0;
}

No comments:

Post a Comment