Advertisement
Vlad_Savitskiy

Sum and composition

Apr 8th, 2020
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.07 KB | None | 0 0
  1. using System;
  2.  
  3. namespace CSLightFirst
  4. {
  5.     class Program
  6.     {
  7.         static void Main()
  8.         {
  9.             Random rand = new Random();
  10.             int[,] data = new int[5, 5];
  11.             int sumSecondRow = 0;
  12.             int compositionFirstCol = 1;
  13.  
  14.             for (int i = 0; i < data.GetLength(0); i++)
  15.             {
  16.                 for (int j = 0; j < data.GetLength(1); j++)
  17.                 {
  18.                     data[i, j] = rand.Next(0, 9);
  19.                     Console.Write(data[i, j] + " ");
  20.                 }
  21.                 Console.WriteLine();
  22.             }
  23.  
  24.             for (int i = 0; i < data.GetLength(1); i++)
  25.                 sumSecondRow += data[1, i];
  26.  
  27.             for (int i = 0; i < data.GetLength(0); i++)
  28.                 compositionFirstCol *= data[i, 0];
  29.  
  30.             Console.WriteLine($"\nСумма второй строки массива равна {sumSecondRow}\n" +
  31.                               $"Произведение первого столбца массива равно {compositionFirstCol}");
  32.         }
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement