Sininerebane

Untitled

Jun 7th, 2024
451
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.35 KB | Software | 0 0
  1. namespace MatrizViseVersa
  2. {
  3.     internal class Program
  4.     {
  5.         static void Main(string[] args)
  6.         {
  7.  
  8.             Console.OutputEncoding = Encoding.UTF8;
  9.             int minValue = 1;
  10.             int maxValue = 10;
  11.             int rowIndex = 0;
  12.             int columnNumber = 1;
  13.             int sumResult = 0;
  14.             int multiplyResult = 1;
  15.             int [,] numbers = new int[3, 3];
  16.             Random random = new Random();
  17.  
  18.             for (int i = 0; i < numbers.GetLength(0); i++)
  19.             {
  20.                 for (int j = 0; j < numbers.GetLength(1); j++)
  21.                 {
  22.                     numbers[i, j] = random.Next(minValue, maxValue);
  23.                     Console.Write(numbers[i, j] + " ");
  24.                 }
  25.                
  26.                 Console.WriteLine();
  27.             }
  28.  
  29.             for (int i = 0; i < numbers.GetLength(0); i++)
  30.             {
  31.                 multiplyResult *= numbers[rowIndex, i];
  32.             }
  33.  
  34.             Console.WriteLine($"Произведение первого столбца: {multiplyResult} ");
  35.  
  36.             for (int j = 0; j < numbers.GetLength(1); j++)
  37.             {
  38.                 sumResult += numbers[columnNumber, j];
  39.             }
  40.  
  41.             Console.WriteLine($"Cумму второй строки: {sumResult} ");
  42.             Console.ReadKey();
  43.         }
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment