Advertisement
voldmaks

Работа с конкретными столбцами и строками

Dec 24th, 2020 (edited)
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.30 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Работа_с_конкретными_столбцами_и_строками
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int[,] array = { { 6, 7, 3, 3 }, { 1, 9, 4, 3 }, { 7, 4, 7, 8 } };
  14.             int sumSecondRow = 0;
  15.             int productFirstColumn = 1;
  16.  
  17.             Console.WriteLine("Исходная матрица:");
  18.             for (int i = 0; i < array.GetLength(0); i++)
  19.             {
  20.                 for (int j = 0; j < array.GetLength(1); j++)
  21.                 {
  22.                     Console.Write(array[i, j] + " ");
  23.                 }
  24.                 Console.WriteLine();
  25.             }
  26.  
  27.             for (int i = 0; i < array.GetLength(1); i++)
  28.             {
  29.                 sumSecondRow += array[1, i];
  30.             }
  31.  
  32.             for (int i = 0; i < array.GetLength(0); i++)
  33.             {
  34.                 productFirstColumn *= array[i, 0];
  35.             }
  36.  
  37.             Console.WriteLine("Сумма второй строки матрицы: " + sumSecondRow);
  38.             Console.WriteLine("Произведение первого столбца матрицы: " + productFirstColumn);
  39.         }
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement