Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace Themostmaxelement
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- Console.OutputEncoding = Encoding.UTF8;
- Random random = new Random();
- int size = 10;
- int[,] array = new int[size, size];
- int maxElement = int.MinValue;
- int minValue = 0;
- int maxValue = 10;
- int replacementMaxNumber = 0;
- for (int i = 0; i < array.GetLength(0); i++)
- {
- for (int j = 0; j < array.GetLength(1); j++)
- {
- array[i, j] = random.Next(minValue, maxValue);
- }
- }
- Console.WriteLine("Исходная матрица\n");
- for (int i = 0; i < array.GetLength(0); i++)
- {
- for (int j = 0; j < array.GetLength(1); j++)
- {
- 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)
- {
- maxElement = array[i, j];
- }
- }
- }
- Console.WriteLine();
- Console.WriteLine($"Наибольший элемент в матрица {maxElement}\n");
- Console.WriteLine("Полученная матрица\n");
- 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] = replacementMaxNumber;
- }
- Console.Write(array[i, j] + " ");
- }
- Console.WriteLine();
- }
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment