Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Text;
- namespace Squares_in_Matrix
- {
- class Program
- {
- static bool IsEqualMatrix(char[,] matrix, int baseMatrixRow, int baseMatrixCol)
- {
- bool result = false;
- if (matrix[baseMatrixRow, baseMatrixCol] == matrix[baseMatrixRow, baseMatrixCol + 1])
- {
- if (matrix[baseMatrixRow, baseMatrixCol] == matrix[baseMatrixRow + 1, baseMatrixCol])
- {
- if (matrix[baseMatrixRow, baseMatrixCol] == matrix[baseMatrixRow + 1, baseMatrixCol + 1])
- {
- result = true;
- }
- }
- }
- return result;
- }// bool IsEqualMatrix(int baseMatrixRow, int baseMatrixCol, int row, int col)
- static void Main(string[] args)
- {
- int[] dimensions = Console.ReadLine().Split(' ', StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
- int rows = dimensions[0];
- int cols = dimensions[1];
- char[,] arr = new char[rows, cols];
- for (int row = 0; row < rows; row++)
- {
- string[] temp = Console.ReadLine().Split(' ', StringSplitOptions.RemoveEmptyEntries);
- for (int col = 0; col < cols; col++)
- {
- arr[row, col] = temp[col][0];
- }
- }
- int numEqualmatrix = 0;
- int endRow = arr.GetLength(0) - 1;
- int endCol = arr.GetLength(1) - 1;
- for (int row = 0; row < endRow; row++)
- {
- for (int col = 0; col < endCol; col++)
- {
- if (IsEqualMatrix(arr, row, col))
- {
- numEqualmatrix++;
- }
- }
- }
- Console.WriteLine(numEqualmatrix);
- }
- }
- }
Advertisement
RAW Paste Data
Copied
Advertisement