Загрузка данных


using System;

namespace TwentySecondApril
{
    class Program
    {
        static void Main(string[] args)
        {
            int rows = 3;
            int columns = 3;
            int diagonalSum = 0;
            int[,] a = new int[rows, columns];

            Console.WriteLine("Введите элементы матрицы 3x3 (9 чисел):");

            for (int i = 0; i < rows; i++)
                for (int k = 0; k < columns; k++)
                    a[i, k] = int.Parse(Console.ReadLine());

            Console.WriteLine("\nМатрица:");
            
            for (int i = 0; i < rows; i++)
            {
                for (int k = 0; k < columns; k++)
                {
                    Console.Write("{0, 4}", a[i, k]); 
                }
                Console.WriteLine();
            }

            for (int i = 0; i < rows; i++)
            {
                diagonalSum += a[i, i];
            }

            Console.WriteLine("\nСумма элементов на главной диагонали: " + diagonalSum);

            Console.ReadKey();
        }
    }
}