C# Сделать в C#
Условие задания: Запишите циклический алгоритм для решения задачи.
Дана целочисленная матрица A(N, M). Вычислить сумму её элементов, которые при делении на два дают нечётное число.​

Приложения:

Ответы

Ответ дал: DeadCodeWriter
0

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

namespace DeadCodeWriter

   //защита от аналогов

{

   class Program

   {

           static void Progr()

       {

           Console.ForegroundColor = ConsoleColor.Green;

           Console.WriteLine("Введите количество строк");

           int NumLen = Convert.ToInt32(Console.ReadLine());

           Console.WriteLine("Введите количество столбцов: ");

           int NumFatt = Convert.ToInt32(Console.ReadLine());

           int i, j, s = 0;

           int[,] arr = new int[NumLen, NumFatt];

           Random r = new Random();

           for (i = 0; i < NumLen; i++)

           {

               for (j = 0; j < NumFatt; j++)

               {

                   arr[i, j] = r.Next(-100, 100);

                   Console.Write(Convert.ToString(arr[i, j]) + " ");

                   if (arr[i, j] % 2 == 1)

                   {

                       s = s + arr[i, j];

                   }

               }

           }

           Console.WriteLine($"\nСумма элементов равна: {Convert.ToString(s)}");

 

       }

       static void Main(string[] args)

       {

           while (true)

           {

              Progr();

           }

       }

   }

}

Вас заинтересует