kwest87

Untitled

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