Advertisement
Torgach

Наибольший_элемент

Oct 5th, 2020
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. using System;
  2. using System.Dynamic;
  3. using System.Globalization;
  4.  
  5. namespace Наибольший_элемент
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. int[,] array = new int[9, 9];
  12.  
  13. int maximumNumber = 0;
  14.  
  15. int column = 0;
  16. int row = 0;
  17.  
  18. Random rand = new Random();
  19.  
  20. Console.WriteLine("Исходная матрица:\n");
  21.  
  22. for (int i = 0; i < array.GetLength(0); i++)
  23. {
  24. for (int j = 0; j < array.GetLength(1); j++)
  25. {
  26. array[i, j] = rand.Next(101, 1000);
  27. Console.Write(array[i, j] + " ");
  28. }
  29. Console.WriteLine();
  30. }
  31.  
  32. Console.WriteLine("\nИзмененная матрица:\n");
  33.  
  34. for (int i = 0; i < array.GetLength(0); i++)
  35. {
  36. for (int j = 0; j < array.GetLength(1); j++)
  37. {
  38. if (array[row,column] < array[i, j])
  39. {
  40. row = i;
  41. column = j;
  42. }
  43. }
  44. }
  45.  
  46. maximumNumber = array[row, column];
  47.  
  48. array[row, column] = 0;
  49.  
  50. for (int i = 0; i < array.GetLength(0); i++)
  51. {
  52. for (int j = 0; j < array.GetLength(1); j++)
  53. {
  54. Console.Write(array[i, j] + " ");
  55. }
  56. Console.WriteLine();
  57. }
  58. Console.WriteLine("\nНаибольший элемент:" + maximumNumber);
  59. }
  60. }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement