Advertisement
Rodunskiy

Untitled

Jun 6th, 2024
421
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.08 KB | None | 0 0
  1. using System;
  2.  
  3. namespace CSLight
  4. {
  5.     public class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int[,] numbers =
  10.             {
  11.             {1,1,1,1 },
  12.             {2,2,2,2 },
  13.             {3,3,3,3 }
  14.             };
  15.  
  16.             int lineIndex1 = 0;
  17.             int lineIndex2 = 1;
  18.             int sum = 0;
  19.             int product = 1;
  20.  
  21.             for (int i = 0; i < numbers.GetLength(0); i++)
  22.             {
  23.                 for (int j = 0; j < numbers.GetLength(1); j++)
  24.                 {
  25.                     Console.Write(numbers[i, j]);
  26.                 }
  27.  
  28.                 Console.WriteLine();
  29.             }
  30.  
  31.             for (int i = 0; i < numbers.GetLength(0); i++)
  32.             {
  33.                 product *= numbers[i, lineIndex1];
  34.             }
  35.  
  36.             for (int i = 0; i < numbers.GetLength(1); i++)
  37.             {
  38.                 sum += numbers[lineIndex2, i];
  39.             }
  40.  
  41.             Console.WriteLine($"Сумма: {sum}");
  42.             Console.WriteLine($"Произведение: {product}");
  43.         }
  44.     }
  45. }
  46.  
  47.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement