kwest87

Untitled

Jan 9th, 2024
1,131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.51 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 sum = 0;
  15.             int multiplication = 1;
  16.             int line = 2;
  17.             int column = 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(0); i++)
  30.             {
  31.                 for (int j = 0; j < numbers.GetLength(1); j++)
  32.                 {
  33.                     if (i == line - correction)
  34.                     {
  35.                         sum += numbers[i, j];
  36.                     }
  37.                 }
  38.             }
  39.  
  40.             for (int i = 0; i < numbers.GetLength(0); i++)
  41.             {
  42.                 for (int j = 0; j < numbers.GetLength(1); j++)
  43.                 {
  44.                     if (j == column - correction)
  45.                     {
  46.                         multiplication *= numbers[i, j];
  47.                     }
  48.                 }
  49.             }
  50.  
  51.             Console.WriteLine($"Сумма {line} строки - {sum}, произведение {column} столбца - {multiplication}.");
  52.         }
  53.     }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment