Dr_Max_Experience

Task 15

Aug 18th, 2021
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.24 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Homework_1
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int numberRow = 1;
  14.             int numberColumn = 0;
  15.             int sumRow = 0;
  16.             int productColumn = 1;
  17.             int[,] array = new int[5, 5];
  18.             Random rand = new Random();
  19.  
  20.             for (int i = 0; i < array.GetLength(0); i++)
  21.             {
  22.                 for (int j = 0; j < array.GetLength(1); j++)
  23.                 {
  24.                     array[i, j] = rand.Next(1, 5);
  25.                     Console.Write(array[i, j] + " ");
  26.                 }
  27.                 Console.WriteLine();
  28.             }
  29.  
  30.             for (int i = 0; i < array.GetLength(0); i++)
  31.             {
  32.                 sumRow += array[numberRow, i];
  33.             }
  34.  
  35.             for (int j = 0; j < array.GetLength(0); j++)
  36.             {
  37.                 productColumn *= array[j, numberColumn];
  38.             }
  39.             Console.WriteLine($"Сумма 2-й строки = {sumRow}\nПроизведение первого столбца = {productColumn}");
  40.             Console.ReadKey();
  41.         }
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment