enum Color
{
Black,White,Red,Yellow,Green
}
boolean paintFill(Color[][] screen,int x,int y,Color ocolor,Color ncolor)
{
if(x<0||x>=screen[0].length||y<0||y>=screen.length)
{
return false;
}
if(screen[y][x]==ocolor)
{
screen[y][x]=ncolor;
paintFill(screen,x-1,y,ocolor,ncolor);//左
paintFill(screen,x+1,y,ocolor,ncolor);//右
paintFill(screen,x,y-1,ocolor,ncolor);//上
paintFill(screen,x,y+1,ocolor,ncolor);//下
}
return true;
}
boolean paintFill(Color [][] screen,int x,int y ,Color ncolor)
{
if(screen[y][x]==ncolor) return false;
return paintFill(screen,x,y,screen[y][x],ncolor);
}
版权声明:本文为博主原创文章,未经博主允许不得转载。
时间: 2024-10-12 21:03:10