Advertisement
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;
- class Program
- {
- static void Main(string[] args)
- {
- int[] size = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
- int[][] matrix = new int[size[0]][];
- int c = 0;
- int d = 0;
- int sum = 0;
- int maxSum = 0;
- for (int i = 0; i < size[0]; i++)
- {
- matrix[i] = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
- }
- for (int i = 0; i < size[0] - 2; i++)
- {
- for (int j = 0; j < size[1] - 2; j++)
- {
- sum = matrix[i][j] + matrix[i][j + 1] + matrix[i][j + 2] + matrix[i + 1][j] + matrix[i + 1][j + 1] + matrix[i + 1][j + 2] + matrix[i + 2][j] + matrix[i + 2][j + 1] + matrix[i + 2][j + 2];
- if (sum > maxSum)
- {
- maxSum = sum;
- c = i;
- d = j;
- }
- }
- }
- Console.WriteLine(maxSum);
- for (int i = c; i < c + 3; i++)
- {
- for (int j = d; j < d + 3; j++)
- {
- Console.Write(matrix[i][j] + " ");
- }
- Console.WriteLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement