Пример #1
0
    private static void FindAdjacent(int[][] blocks, int color, RC rc, List <RC> cells)
    {
        if (!rc.IsValid() || cells.Contains(rc) || blocks[rc.Row][rc.Column] <= 0)
        {
            return;
        }

        if (blocks[rc.Row][rc.Column] == color)
        {
            cells.Add(rc);
            FindAdjacent(blocks, color, new RC(rc.Row + 1, rc.Column), cells);
            FindAdjacent(blocks, color, new RC(rc.Row - 1, rc.Column), cells);
            FindAdjacent(blocks, color, new RC(rc.Row, rc.Column + 1), cells);
            FindAdjacent(blocks, color, new RC(rc.Row, rc.Column - 1), cells);
        }
    }