На каком языке это нужно реализовать?Вот C#
Console.Write("Введите количество строк: ");
int rows = Convert.ToInt32(Console.ReadLine());
Console.Write("Введите количество столбцов: ");
int columns = Convert.ToInt32(Console.ReadLine());
int[,] matrix = new int[rows, columns];
int sumRows = 0;
int sumColumns = 0;
for (int i = 0; i < rows;i++)
{
for (int j = 0; j < columns;j++)
{
Console.Write($"Введите элемент [{i},{j}]: ");
int number = Convert.ToInt32(Console.ReadLine());
matrix[i, j] = number;
if (i == 0 || i == rows - 1) sumRows += number;
if (j == 0 || j == columns - 1) sumColumns += number;
}
}
for (int i = 0; i < rows;i++)
{
for (int j = 0; j < columns;j++)
{
Console.Write($"{matrix[i, j]}\t");
}
Console.WriteLine();
}
Console.WriteLine($"Сумма элементов на первой и последней строке: {sumRows}");
Console.WriteLine($"Сумма элементов на первом и последнем столбце: {sumColumns}");
Console.ReadLine();