static bool AccessibleCell(Cell cell) { long rows = Matrix.GetLongLength(0); long cols = Matrix.GetLongLength(1); int row = cell.X; int col = cell.Y; if (row < 0 || row >= rows ||col < 0 || col >= cols ||Matrix[row, col] != "0") { return false; } return true; }
static void VisitCell(Cell cell) { if (AccessibleCell(cell)) { VisitedCells.Enqueue(cell); Matrix[cell.X, cell.Y] = cell.Value.ToString(); } }