lovelyvook

Unit_18

Jun 16th, 2024 (edited)
719
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.37 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Ijunior
  4. {
  5.     internal class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int row = 4;
  10.             int column = 4;
  11.             int[,] numbers = new int[row, column];
  12.             int multiplication = 1;
  13.             int sum = 0;
  14.             int columnForMultiplication = 0;
  15.             int rowForSum = 1;
  16.             Random random = new Random();
  17.             int minRandomNumber = 1;
  18.             int maxRandomNumber = 10;
  19.  
  20.             for (int i = 0; i < numbers.GetLength(0); i++)
  21.             {
  22.                 for (int j = 0; j < numbers.GetLength(1); j++)
  23.                 {
  24.                     numbers[i, j] = random.Next(minRandomNumber, maxRandomNumber);
  25.                     Console.Write(numbers[i, j] + " ");
  26.                 }
  27.  
  28.                 Console.WriteLine();
  29.             }
  30.  
  31.             for (int i = 0; i < numbers.GetLength(0); i++)
  32.             {
  33.                 multiplication *= numbers[i, columnForMultiplication];
  34.             }
  35.  
  36.             for (int i = 0; i < numbers.GetLength(1); i++)
  37.             {
  38.                 sum += numbers[rowForSum, i];
  39.             }
  40.  
  41.             Console.WriteLine($"Сумма {rowForSum + 1} ряда: " + sum);
  42.             Console.WriteLine($"Произведение {columnForMultiplication + 1} столбца: " + multiplication);
  43.         }
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment