Advertisement
rukvir

HW 3_1_1

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