Beispiel #1
0
        private static void FindNextCell(int currentRow, int currentCol, MatrixInfo matrixInfo)
        {
            if (!IsInside(currentRow, currentCol) || matrix[currentRow][currentCol] != '-')
            {
                return;
            }

            matrix[currentRow][currentCol] = '0';
            matrixInfo.IncrementSize();

            FindNextCell(currentRow - 1, currentCol, matrixInfo);

            FindNextCell(currentRow + 1, currentCol, matrixInfo);

            FindNextCell(currentRow, currentCol - 1, matrixInfo);

            FindNextCell(currentRow, currentCol + 1, matrixInfo);
        }
Beispiel #2
0
        private static void GetMatrixInfo()
        {
            for (int row = 0; row < matrix.Length; row++)
            {
                for (int col = 0; col < matrix[row].Length; col++)
                {
                    var currentCell = matrix[row][col];

                    if (currentCell == '-')
                    {
                        MatrixInfo matrixInfo = new MatrixInfo(row, col, 0);

                        FindNextCell(row, col, matrixInfo);

                        infos.Add(matrixInfo);
                    }
                }
            }
        }