Advertisement
RedFlys

HomeWork15. Work with array

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