C#

С # Дан двумерный массив целых чисел размером m*n. Заполнить его с клавиатуры.

Подсчитать количество элементов, не превосходящих по модулю 10;
 подсчитать в каждой строке и в каждом столбце сумму нечетных элементов;
 увеличить в 2 раза все отрицательные элементы;
 вывести массив на экран до и после изменения.
using System;
class Program
{
static void Main()
{
int m, n;
Console.Write("Number of rows:");
m = Convert.ToInt32(Console.ReadLine());
Console.Write("Number of columns:");
n = Convert.ToInt32(Console.ReadLine());
int[,] A = new int[m, n];
for(int i = 0; i < m; i++)
for(int j = 0; j < n; j++)
{
Console.Write($"A[{i}, {j}] = ");
A[i, j] = Convert.ToInt32(Console.ReadLine());
}
/*Filling an array with random numbers*/
/*Random rnd = new Random();
for(int i = 0; i < m; i++)
for(int j = 0; j < n; j++)
A[i, j] = rnd.Next(-50, 50);*/
for(int i = 0; i < m; i++)
{
for(int j = 0; j < n; j++)
Console.Write($"{A[i, j],3} ");
Console.WriteLine();
}
int c = 0;
for(int i = 0; i < m; i++)
for(int j = 0; j < n; j++)
if(Math.Abs(A[i, j]) < 10)
c++;
Console.WriteLine($"The number of elements is less than 10 in absolute value: {c}");
Console.WriteLine("Sum of odd elements by rows:");
for(int i = 0; i < m; i++)
{
int s = 0;
for(int j = 0; j < n; j++)
if(A[i, j] % 2 != 0)
s += A[i, j];
Console.WriteLine(s);
}
Console.WriteLine("Sum of odd elements by columns:");
for(int j = 0; j < n; j++)
{
int s = 0;
for(int i = 0; i < m; i++)
if(A[i, j] % 2 != 0)
s += A[i, j];
Console.Write($"{s} ");
} Console.WriteLine();
for(int i = 0; i < m; i++)
{
for(int j = 0; j < n; j++)
{
if(A[i, j] < 0)
A[i, j] *= 2;
Console.Write($"{A[i, j],3} ");
}
Console.WriteLine();
}
}
}
Юра Кривий
Юра Кривий
11 953
Лучший ответ
Сергей Михайлов спасибо !!!Все работает :)