Advertisement
asvd32

17

Feb 19th, 2025
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.56 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp3
  4. {
  5.     internal class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int matrixRow = 3;
  10.             int matrixColumn = 3;
  11.             int[,] matrix = new int[matrixRow, matrixColumn];
  12.  
  13.             Random random = new Random();
  14.             int randomMaxRange = 100;
  15.             int randomMinRange = 11;
  16.  
  17.             int rowIndex;
  18.             int columnIndex;
  19.  
  20.             int summRowIndex = 1;
  21.             int multColumnIdex = 0;
  22.             int summResult = 0;
  23.             int multResult = 1;
  24.  
  25.             for (rowIndex = 0; rowIndex < matrix.GetLength(0); rowIndex++)
  26.             {
  27.                 for (columnIndex = 0; columnIndex < matrix.GetLength(1); columnIndex++)
  28.                 {
  29.                     matrix[rowIndex, columnIndex] = random.Next(randomMinRange, randomMaxRange);
  30.                     Console.Write(matrix[rowIndex, columnIndex] + " ");
  31.  
  32.                     if (rowIndex == summRowIndex)
  33.                     {
  34.                         summResult += matrix[rowIndex, columnIndex];
  35.                     }
  36.  
  37.                     if (columnIndex == multColumnIdex)
  38.                     {
  39.                         multResult *= matrix[rowIndex, columnIndex];
  40.                     }
  41.                 }
  42.                 Console.WriteLine();            
  43.             }
  44.             Console.WriteLine($"\nСумма второй строки равна = {summResult}.\n" +
  45.                    $"Произведение первого столбца = {multResult}.");
  46.         }
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement