Advertisement
illiden

Row-Column

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