Advertisement
RedFlys

Home Work 3.3

Nov 1st, 2019
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.16 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 ConsoleApp3
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int sum = 0;
  14.             int product = 1;
  15.             int[,] array = new int[3,3];
  16.            
  17.  
  18.  
  19.             Random random = new Random();
  20.  
  21.             for (int i = 0; i < array.GetLength(0); i++)
  22.             {
  23.                 for (int j = 0; j < array.GetLength(1); j++)
  24.                 {
  25.                     array[i,j] = random.Next(0, 20);
  26.                     Console.Write(array[i,j] + " ");
  27.                 }
  28.                 Console.WriteLine();
  29.             }
  30.  
  31.             for (int j = 0;  j < array.GetLength(1); j++)
  32.             {
  33.                 sum += array[1, j];
  34.             }
  35.  
  36.             for (int i = 0; i < array.GetLength(0); i++)
  37.             {
  38.                 product *= array[i, 0];
  39.             }
  40.  
  41.             Console.WriteLine($"\nСумма второй строки = {sum}, произведение первого столбца = {product}");
  42.  
  43.             Console.ReadKey();
  44.         }
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement