kwest87

Untitled

Mar 28th, 2022
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.40 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.             int line2 = 1;
  18.             int pillar1 = 0;
  19.             Random random = new Random();
  20.  
  21.             for (int i = 0; i < places.GetLength(0); i++)
  22.             {
  23.  
  24.                 for (int j = 0; j < places.GetLength(1); j++)
  25.                 {
  26.                     Console.Write(places[i, j]=random.Next(1,10));
  27.                    
  28.                 }
  29.                 Console.WriteLine();
  30.             }
  31.             for (int i = 0; i < places.GetLength(0); i++)
  32.             {
  33.  
  34.                 for (int j = 0; j < places.GetLength(1); j++)
  35.                 {
  36.                     if (i == line2)
  37.                     {
  38.                         sum = sum + places[i, j];
  39.                     }
  40.                     if (j == pillar1)
  41.                     {
  42.                         product = product * places[i, j];
  43.                     }
  44.                 }
  45.             }
  46.  
  47.             Console.WriteLine("Сумма второй строки " + sum + ". Произведение первого столбца " + product + ".");
  48.         }
  49.     }
  50. }
  51. [EndCode]
  52.  
Advertisement
Add Comment
Please, Sign In to add comment