using System;
namespace CyberForum
{
class Program
{
static void Main()
{
Random rand = new Random();
const int n = 10;
int[,] matrix = new int[n, n];
for (int i = 0; i < n; i++)
{
for (int j = 0; j < n; j++)
{
matrix[i, j] = rand.Next(0, 1000);
}
}
Func<int, int, bool> inLeftTopSquare = (y, x) => x < n / 2 && y < n / 2;
Func<int, int, bool> inRightBottom = (y, x) => x >= n / 2 && x <= y;
Func<int, int, bool> inLeftBottom = (y, x) => y >= n / 2 && x < n - y;
int maxElement = matrix[0, 0];
for (int y = 0; y < n; y++)
{
for (int x = 0; x < n; x++)
{
if (matrix[y, x] > maxElement)
maxElement = matrix[y, x];
if (inLeftTopSquare(y, x)) Console.ForegroundColor = ConsoleColor.Red;
else if (inRightBottom(y, x)) Console.ForegroundColor = ConsoleColor.Green;
else if (inLeftBottom(y, x)) Console.ForegroundColor = ConsoleColor.Blue;
Console.Write(matrix[y, x].ToString().PadLeft(5));
Console.ResetColor();
}
Console.WriteLine();
}
Console.WriteLine("\nМаксимальный элемент: " + maxElement);
}
}
}