Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Homework21
- {
- class Program
- {
- static void Main()
- {
- int[,] matrix = new int[10, 10];
- int maxElementInMatrix = int.MinValue;
- int zeroElement = 0;
- Random random = new Random();
- for (int i = 0; i < matrix.GetLength(0); i++)
- {
- for (int j = 0; j < matrix.GetLength(1); j++)
- {
- matrix[i, j] = random.Next(1, 51);
- }
- }
- Console.WriteLine($"Исходная матрица:\n ");
- for (int i = 0; i < matrix.GetLength(0); i++)
- {
- for (int j = 0; j < matrix.GetLength(1); j++)
- {
- Console.Write(matrix[i, j] + " ");
- }
- Console.WriteLine();
- }
- for (int i = 0; i < matrix.GetLength(0); i++)
- {
- for (int j = 0; j < matrix.GetLength(1); j++)
- {
- if (matrix[i, j] > maxElementInMatrix)
- {
- maxElementInMatrix = matrix[i, j];
- }
- }
- }
- for (int i = 0; i < matrix.GetLength(0); i++)
- {
- for (int j = 0; j < matrix.GetLength(1); j++)
- {
- if (maxElementInMatrix == matrix[i, j])
- {
- matrix[i, j] = zeroElement;
- }
- }
- }
- Console.WriteLine($"\nМаксимальный элемент матрицы: {maxElementInMatrix}.");
- Console.WriteLine("\nИзмененная матрица:\n ");
- for (int i = 0; i < matrix.GetLength(0); i++)
- {
- for (int j = 0; j < matrix.GetLength(1); j++)
- {
- Console.Write(matrix[i, j] + " ");
- }
- Console.WriteLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement