边界表示的4连通区域的递归填充算法
边界表示的4连通区域的递归填充算法
#include<stdio.h>
#include<graphics.h>
void BoundaryFill4(int x,int y,int boundarycolor,int newcolor)
{ int color; /*color怎么取值*/
if(color!=newcolor && color!=boundarycolor)
{putpixel(x,y,newcolor);
BoundaryFill4 (x,y+1, boundarycolor,newcolor);
BoundaryFill4 (x,y-1, boundarycolor,newcolor);
BoundaryFill4 (x-1,y, boundarycolor,newcolor);
BoundaryFill4 (x+1,y, boundarycolor,newcolor);
}
}
main()
{
int gdriver=DETECT, gmode;
int x1=160,y1=60,r1=60;
initgraph(&gdriver, &gmode," ");
circle(x1,y1,r1);
BoundaryFill4(x1,y1,getbkcolor(),RED);
getch();
closegraph();
}
请大家看看啊,谢谢