lolblach333

Untitled

Apr 15th, 2019
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. using System;
  2.  
  3.  
  4. namespace Largest_Matrix_Element
  5. {
  6. class Program
  7. {
  8. private const string
  9. InitialArray = "Матрица: ",
  10. MaxElement = "Максимальный элимент: ",
  11. ResultMatrix = "Матрица без Максимума: ",
  12. EmptySpace = " ";
  13.  
  14. private const int Min = 1, Max = 20, MatrixSize = 10;
  15.  
  16. static void Main(string[] args)
  17. {
  18. int[,] matrix = new int[MatrixSize, MatrixSize];
  19. int maxI = 0, maxJ = 0;
  20.  
  21. Random random = new Random();
  22. Console.WriteLine(InitialArray);
  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 (matrix[maxI, maxJ] < matrix[i, j])
  32. {
  33. maxI = i;
  34. maxJ = j;
  35. }
  36. }
  37.  
  38. Console.WriteLine();
  39. }
  40.  
  41. Console.WriteLine();
  42. Console.WriteLine(MaxElement);
  43. Console.WriteLine(matrix[maxI, maxJ]);
  44. Console.WriteLine();
  45. Console.WriteLine(ResultMatrix);
  46.  
  47. matrix[maxI, maxJ] = 0;
  48.  
  49. for (int i = 0; i < MatrixSize; i++)
  50. {
  51. for (int j = 0; j < MatrixSize; j++)
  52. {
  53. Console.Write(matrix[i, j] + EmptySpace);
  54. }
  55.  
  56. Console.WriteLine();
  57. }
  58.  
  59. Console.ReadKey();
  60. }
  61. }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment