Advertisement
trmaxa2820

CSharpTask

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