我们都知道Windows的画图里面有个油漆桶工具,可以把选中的封闭区域都填充成自定义的颜色,这就是填充算法的应用。我在这里用Ncurses写成了一个小的填充算法的程序,看下图:
程序控制
程序运行期间,输入区域编号就可以使用‘+’填充该区域。
算法思想
这个算法还是广度搜索算法,只是遇到边界的时候(选定区域的边界)就不继续进行向外探索。
小工具代码
|
|
总结
这个小程序是我一个多小时两个小时裸写的,虽然广度搜索算法真的非常简单,但还是挺有成就感的。
My head's under water, but I'm breathing fine.
我们都知道Windows的画图里面有个油漆桶工具,可以把选中的封闭区域都填充成自定义的颜色,这就是填充算法的应用。我在这里用Ncurses写成了一个小的填充算法的程序,看下图:
程序运行期间,输入区域编号就可以使用‘+’填充该区域。
这个算法还是广度搜索算法,只是遇到边界的时候(选定区域的边界)就不继续进行向外探索。
|
|
这个小程序是我一个多小时两个小时裸写的,虽然广度搜索算法真的非常简单,但还是挺有成就感的。