Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Program
- {
- static void Main(string[] args)
- {
- int[,] array = new int[10, 10];
- int maxElement = int.MinValue;
- Random ran = new Random();
- for (int i = 0; i < array.GetLength(0); i++)
- {
- for (int j = 0; j < array.GetLength(1); j++)
- {
- array[i, j] = ran.Next(1, 100);
- if (maxElement < array[i, j]) { maxElement = array[i, j]; }
- if (array[i, j] <= 9)
- {
- Console.Write(array[i, j] + " ");
- }
- else { Console.Write(array[i, j] + " "); }
- }
- Console.WriteLine("");
- }
- for (int i = 0; i < array.GetLength(0); i++)
- {
- for (int j = 0; j < array.GetLength(1); j++)
- {
- if (array[i, j] == maxElement) { array[i, j] = 0; }
- }
- }
- Console.WriteLine("-------------------------------");
- for (int i = 0; i < array.GetLength(0); i++)
- {
- for (int j = 0; j < array.GetLength(1); j++)
- {
- if(array[i,j]<=9)
- Console.Write(array[i,j] + " ");
- else
- Console.Write(array[i, j] + " ");
- }
- Console.WriteLine("");
- }
- Console.WriteLine($"\nНаибольший элемент {maxElement}");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement