using System;
internal class Program
{
static void Main(string[] args)
{
int[,] table = {
{ 1, 2, 3, 4, 5 },
{ 7, 8, 9, 6, 4 },
{ 8, 9, 5, 6, 7 },
{ 8, 9, 3, 4, 21 },
{ 9, 10, 5, 6, 7 }
};
int sum=0;
Console.WriteLine("Tablica to: \n");
for (int i=0; i<table.GetLength(0); i++)
{
for (int j=0; j<table.GetLength(1); j++)
{
if (i==j)
{
Console.ForegroundColor = ConsoleColor.Green;
Console.Write("{0,-3}", table[i, j]);
Console.ResetColor();
sum += table[i, j];
}
else
Console.Write("{0,-3}", table[i, j]);
}
Console.WriteLine();
}
Console.Write("\nSuma elementów na przekątnej to: " + sum);
}
}