📄 flfill.c
字号:
/* Bai tap 2_30 - Thuat toan to mau Flood Fill
Chu y : Thuat toan su dung de quy, do do doi voi mien lon co the
gay tran stack
*/
#include <graphics.h>
#include <conio.h>
void FloodFill (int x, int y, int in_color, int new_color)
{
if (getpixel(x, y) == in_color)
{
putpixel(x, y, new_color);
FloodFill(x-1, y, in_color, new_color);
FloodFill(x+1, y, in_color, new_color);
FloodFill(x, y-1, in_color, new_color);
FloodFill(x, y+1, in_color, new_color);
}
}
void main()
{
int gr_drive = DETECT, gr_mode;
initgraph(&gr_drive, &gr_mode, "");
circle(getmaxx() / 2, getmaxy() / 2, 15);
FloodFill(getmaxx() / 2, getmaxy() / 2, 0, 4);
getch();
closegraph();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -