using System;
namespace TwentySecondApril
{
class Program
{
static void Main(string[] args)
{
int rows = 3;
int columns = 3;
int S = 0;
int[,] a = new int[rows, columns];
Console.WriteLine("Введите элементы матрицы 3x3 (9 чисел):");
for (int i = 0; i < columns; i++)
for (int k = 0; k < rows; k++)
a[k, i] = int.Parse(Console.ReadLine());
foreach (int num in a) S += num;
Console.WriteLine("\nПолученная матрица:");
for (int k = 0; k < rows; k++)
{
for (int i = 0; i < columns; i++)
{
Console.Write("{0, 4}", a[k, i]);
}
Console.WriteLine();
}
Console.WriteLine("\nСумма всех элементов: " + S);
int diagonalSum = 0;
for (int i = 0; i < rows; i++)
{
diagonalSum += a[i, i];
}
Console.WriteLine("Сумма элементов на главной диагонали: " + diagonalSum);
Console.ReadKey();
}
}
}