Advertisement
RamGaal

HomeWork 3 ex.3

May 17th, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.79 KB | None | 0 0
  1. using System;
  2.  
  3. class MainClass {
  4.   public static void Main (string[] args) {
  5. int [,] matrix = new int[3,3];
  6. int summ2 =0;
  7. int proizvedenie1 = 1;
  8. Random rnd = new Random ();
  9.  
  10.  Console.WriteLine("Исходная матрица\n");
  11.  
  12.  for (int x=0; x< matrix.GetLength(0);x++)
  13.  {
  14. for (int y=0; y < matrix.GetLength(1);y++)
  15.  {
  16. matrix [x,y] = rnd.Next(0,10);
  17. Console.Write(matrix[x,y] + " ");
  18.  }
  19. Console.WriteLine();
  20.  }
  21. for (int y=0;y<matrix.GetLength(1);y++)
  22.  {
  23.  
  24. summ2 += matrix [1,y];
  25.  }
  26.  
  27. for (int x=0;x<matrix.GetLength(0);x++)
  28.  {
  29. proizvedenie1 = proizvedenie1 * matrix [x,0];
  30.  }
  31.  
  32.  Console.WriteLine("Сумма второй строки = " + summ2);
  33.  Console.WriteLine("Произведение первого столбца = " + proizvedenie1);
  34.  Console.ReadKey();
  35.   }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement