SHARE
TWEET
Untitled
a guest
Jan 29th, 2018
75
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace PlaygroundConsole
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] size = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
- .Select(int.Parse).ToArray();
- char[,] matrix = new char[size[0], size[1]];
- for (int i = 0; i < matrix.GetLength(0); i++)
- {
- char[] tokens = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
- .Select(char.Parse).ToArray();
- for (int j = 0; j < matrix.GetLength(1); j++)
- {
- matrix[i, j] = tokens[j];
- }
- }
- int equalSquares = 0;
- for (int i = 0; i < matrix.GetLength(0) - 1; i++)
- {
- for (int j = i; j < matrix.GetLength(1) - 1; j++)
- {
- char startChar = matrix[i, j];
- if ((matrix[i, j + 1] == startChar)
- && (matrix[i + 1, j] == startChar)
- && (matrix[i + 1, j + 1] == startChar))
- {
- equalSquares++;
- }
- }
- }
- Console.WriteLine(equalSquares);
- }
- }
- }
RAW Paste Data

