NikaBang

ДЗ: Работа с конкретными строками/столбцами

Oct 19th, 2025
2,052
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.93 KB | Gaming | 0 0
  1. internal class Program
  2. {
  3.     static void Main(string[] args)
  4.     {
  5.         int line = 1;
  6.         int column = 0;
  7.         int sum = 0;
  8.         int productOfNumbers = 1;
  9.  
  10.         int[,] arrya = {
  11.             { 1, 2, 3 },
  12.             { 4, 5, 6 },
  13.             { 7, 8, 9 }
  14.         };
  15.  
  16.         for (int i = 0; i < arrya.GetLength(1); i++)
  17.         {
  18.             sum += arrya[line, i];
  19.         }
  20.  
  21.         for (int i = 0;i < arrya.GetLength(0); i++)
  22.         {
  23.             productOfNumbers *= arrya[i, column];
  24.         }
  25.  
  26.         for(int i = 0; i < arrya.GetLength(0) ; i++)
  27.         {
  28.             for (int j = 0; j < arrya.GetLength(1); j++)
  29.             {
  30.                 Console.Write(arrya[i, j] + " ");
  31.             }
  32.             Console.WriteLine();
  33.         }
  34.  
  35.         Console.WriteLine($"сумма второй строки - {sum},\nпроизведение первого столбца - {productOfNumbers}.");
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment