kwest87

Untitled

Jan 9th, 2024
605
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.21 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp20
  4. {
  5.     internal class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int[,] numbers = {
  10.                 { 1, 2, 3 },
  11.                 { 4, 5, 6 },
  12.                 { 7, 8, 9 } };
  13.             int correction = 1;
  14.             int lineSum = 0;
  15.             int columnMultiplication = 1;
  16.             int matrixLine = 2;
  17.             int matrixColumn = 1;
  18.  
  19.             for (int i = 0; i < numbers.GetLength(0); i++)
  20.             {
  21.                 for (int j = 0; j < numbers.GetLength(1); j++)
  22.                 {
  23.                     Console.Write(numbers[i, j] + " ");
  24.                 }
  25.  
  26.                 Console.WriteLine();
  27.             }
  28.  
  29.             for (int i = 0; i < numbers.GetLength(1); i++)
  30.             {
  31.                 lineSum += numbers[matrixLine - correction, i];
  32.             }
  33.  
  34.             for (int i = 0; i < numbers.GetLength(0); i++)
  35.             {
  36.                 columnMultiplication *= numbers[i, matrixColumn - correction];
  37.             }
  38.  
  39.             Console.WriteLine($"Сумма {matrixLine} строки - {lineSum}, произведение {matrixColumn} столбца - {columnMultiplication}.");
  40.         }
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment