Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class MatrixBiggerSum
- {
- static void Main()
- {
- string[,] matrix = {
- {"ha", "hifi", "ho", "hi"},
- {"fo", "ha", "fi", "ha"},
- {"xxx", "ho", "ha", "xx"},
- };
- //string[,] matrix = {
- // {"s", "qq", "s"},
- // {"pp", "pp", "s"},
- // {"pp", "qq", "s"},
- //};
- int countVertical = 0;
- int countHorizontal = 0;
- int countDiagonalLeftUp = 0;
- int countDiagoanlRightUp = 0;
- string strVertical = null;
- string strHorizontal = null;
- string strDiagonalLeftUp = null;
- string strDiagonalRightUp = null;
- // Vertical - row
- for (int row = 0; row <
- matrix.GetLength(0); row++)
- {
- int currentCount = 0;
- for (int col = 0; col < matrix.GetLength(1) - 1; col++)
- {
- if (matrix[row, col] == matrix[row, col + 1])
- {
- currentCount++;
- }
- else
- {
- currentCount = 0;
- }
- if (countVertical < currentCount)
- {
- countVertical = currentCount;
- strVertical = matrix[row, col];
- }
- }
- }
- // Print the result
- Console.WriteLine("It is:");
- for (int i = 0; i <= countVertical; i++)
- {
- Console.Write(strVertical + " ");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement