1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
void seek_for_cluster (board b, int color, int coor_x, int coor_y, int cluster_n)
{
if (b.is_clustered[coor_x][coor_y]==0)
{
if (b.color[coor_x][coor_y]==color)
{
b.is_clustered[coor_x][coor_y]=1;
b.cluster_n[coor_x][coor_y]=cluster_n;
if (coor_x>0) seek_for_cluster (b, color, coor_x-1, coor_y, cluster_n);
if (coor_y>0) seek_for_cluster (b, color, coor_x, coor_y-1, cluster_n);
if (coor_x<size_x-1) seek_for_cluster (b, color, coor_x+1, coor_y, cluster_n);
if (coor_y<size_y-1) seek_for_cluster (b, color, coor_x, coor_y+1, cluster_n);
}
}
}
|