lolblach333

Untitled

Apr 15th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. using System;
  2.  
  3.  
  4. namespace Matrix_Calculations
  5. {
  6. class Program
  7. {
  8. private const string
  9. Matrix = "Матрица: ",
  10. Sum = "Сумма второй строки: ",
  11. Composition = "Произвидение первого столбца: ",
  12. EmptySpace = " ";
  13. private const int
  14. Min = 1, Max = 20, MatrixSize = 3;
  15.  
  16. static void Main(string[] args)
  17. {
  18. int[,] matrix = new int[MatrixSize, MatrixSize];
  19. int sum = 0, composition = 1;
  20.  
  21. Random random = new Random();
  22. Console.WriteLine(Matrix);
  23.  
  24. for (int i = 0; i < MatrixSize; i++)
  25. {
  26. for (int j = 0; j < MatrixSize; j++)
  27. {
  28. matrix[i, j] = random.Next(Min, Max);
  29. Console.Write(matrix[i, j] + EmptySpace);
  30.  
  31. if (i == 1)
  32. {
  33. sum += matrix[i, j];
  34. }
  35.  
  36. if (j == 0)
  37. {
  38. composition *= matrix[i, j];
  39. }
  40. }
  41.  
  42. Console.WriteLine();
  43. }
  44.  
  45. Console.WriteLine();
  46. Console.WriteLine(Sum + sum);
  47. Console.WriteLine(Composition + composition);
  48. Console.ReadKey();
  49. }
  50. }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment