Advertisement
JohnJuly

Homework20

Nov 25th, 2023 (edited)
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.52 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 Homework20_2
  8. {
  9.     internal class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int composition = 1;
  14.             int sum = 0;
  15.             int indexSecondStringArray = 1;
  16.             int indexFirstColumnArray = 0;
  17.            
  18.             int[,] array = new int[3, 4]
  19.             {
  20.                 { 5, 2, 3, 4},
  21.                 { 2, 8, 4, 2},
  22.                 { 3, 5, 9, 1}
  23.             };
  24.            
  25.             Console.WriteLine("Дан двумерный массив чисел:\n");
  26.  
  27.             for (int i = 0; i < array.GetLength(0); i++)
  28.             {
  29.                 for (int j = 0; j < array.GetLength(1); j++)
  30.                 {  
  31.                     Console.Write(array[i,j] + " ");
  32.                 }
  33.                
  34.                 Console.WriteLine();
  35.             }
  36.            
  37.             for (int i = 0; i < array.GetLength(0); i++)
  38.             {          
  39.                 composition *= array[indexFirstColumnArray,i];
  40.             }
  41.            
  42.             for( int j = 0; j < array.GetLength(1); j++)
  43.             {
  44.                 sum += array[indexSecondStringArray,j];
  45.             }
  46.            
  47.             Console.WriteLine($"\nСумма его второй строки равна : {sum}\n");
  48.             Console.WriteLine($"Произведение его первого столбца равно: {composition}");
  49.         }
  50.     }
  51. }
  52.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement