Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace HomeWork
- {
- internal class Program
- {
- public static void Main(string[] args)
- {
- Random random = new Random();
- int min = 1;
- int max = 9;
- int targetNumber = 0;
- int rows = 10;
- int columns = 10;
- int[,] matrix = new int[rows, columns];
- Console.WriteLine("Исходная матрица:\n");
- for (int i = 0; i < matrix.GetLength(0); i++)
- {
- for (int j = 0; j < matrix.GetLength(1); j++)
- {
- matrix[i, j] = random.Next(min, max + 1);
- Console.Write(matrix[i, j] + " ");
- }
- Console.WriteLine();
- }
- int maxValue = matrix[0, 0];
- for (int i = 0; i < matrix.GetLength(0); i++)
- {
- for (int j = 0; j < matrix.GetLength(1); j++)
- {
- if (maxValue < matrix[i, j])
- maxValue = matrix[i, j];
- }
- }
- Console.WriteLine("Наибольший элемент матрицы: " + maxValue + "\n");
- Console.WriteLine("Итоговая матрица:\n");
- for (int i = 0; i < matrix.GetLength(0); i++)
- {
- for (int j = 0; j < matrix.GetLength(1); j++)
- {
- if (maxValue == matrix[i, j])
- matrix[i, j] = targetNumber;
- Console.Write(matrix[i, j] + " ");
- }
- Console.WriteLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment