Home  >  Article  >  Backend Development  >  困扰了好几天的一个算法,该怎么处理

困扰了好几天的一个算法,该怎么处理

WBOY
WBOYOriginal
2016-06-13 12:46:34754browse

困扰了好几天的一个算法

本帖最后由 shenyulv 于 2013-05-01 01:13:36 编辑 求一个算法 思路



如上图,大概是一个 “against”字样,由“1”组成,然后再它的周边还有一些零散的“1”,我现在想把这些零散的“1”去掉。我的思路是想通过计算连接在一起的“1”的数量,当它的数量未超过一个常数时,将它们置为0,以取到存的字块。

简单说,我就是想获取由“1”组成的图案有多少个“1”,比如图中的a由多少个“1”组成。这个算法要怎么写,本人算法是在是太烂了
算法 Color
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn