Advertisement
Werjil

Untitled

Dec 6th, 2019
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. class Program
  2. {
  3. static void Main(string[] args)
  4. {
  5. int[,] array = new int[10, 10];
  6. int maxElement = int.MinValue;
  7. Random ran = new Random();
  8.  
  9. for (int i = 0; i < array.GetLength(0); i++)
  10. {
  11. for (int j = 0; j < array.GetLength(1); j++)
  12. {
  13. array[i, j] = ran.Next(1, 100);
  14. if (maxElement < array[i, j]) { maxElement = array[i, j]; }
  15. if (array[i, j] <= 9)
  16. {
  17. Console.Write(array[i, j] + " ");
  18. }
  19. else { Console.Write(array[i, j] + " "); }
  20. }
  21. Console.WriteLine("");
  22. }
  23.  
  24. for (int i = 0; i < array.GetLength(0); i++)
  25. {
  26. for (int j = 0; j < array.GetLength(1); j++)
  27. {
  28. if (array[i, j] == maxElement) { array[i, j] = 0; }
  29. }
  30. }
  31. Console.WriteLine("-------------------------------");
  32.  
  33. for (int i = 0; i < array.GetLength(0); i++)
  34. {
  35. for (int j = 0; j < array.GetLength(1); j++)
  36. {
  37. if(array[i,j]<=9)
  38. Console.Write(array[i,j] + " ");
  39. else
  40. Console.Write(array[i, j] + " ");
  41. }
  42. Console.WriteLine("");
  43. }
  44.  
  45. Console.WriteLine($"\nНаибольший элемент {maxElement}");
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement