Advertisement
rukvir

HW 3_1_2

Mar 12th, 2025
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.31 KB | None | 0 0
  1. using System;
  2.  
  3. namespace HomeWork
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int sumSecondRow = 0;
  10.             int productFirstColumn = 1;
  11.             int numberLine = 1;
  12.             int numberColumn = 0;
  13.  
  14.             int[,] userArray = {
  15.             { 1, 2, 3, 10},
  16.             { 4, 5, 6, 11},
  17.             { 7, 8, 9, 12 }
  18.             };
  19.  
  20.             Console.WriteLine("Исходная матрица:");
  21.  
  22.             for (int x = 0; x < userArray.GetLength(0); x++)
  23.             {
  24.                 for (int y = 0; y < userArray.GetLength(1); y++)
  25.                 {
  26.                     Console.Write(userArray[x, y] + "\t");
  27.                 }
  28.                 Console.WriteLine();
  29.             }
  30.  
  31.             for (int x = 0; x < userArray.GetLength(1); x++)
  32.             {
  33.                 sumSecondRow += userArray[numberLine, x];
  34.             }
  35.  
  36.             for (int y = 0; y < userArray.GetLength(0); y++)
  37.             {
  38.                 productFirstColumn *= userArray[y, numberColumn];
  39.             }
  40.  
  41.             Console.WriteLine($"Сумма второй строки = {sumSecondRow}");
  42.             Console.WriteLine($"Произведение первого столбца = {productFirstColumn}");
  43.  
  44.             Console.ReadKey();
  45.         }
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement