Advertisement
nikitaTheSlayer

Lesson: array1

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