Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace homeWorkTheLargestElement
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- Random random = new Random();
- int countRaw = 10;
- int countColumn = 10;
- int minValue = 10;
- int maxValue = 99;
- int changedValue = 0;
- int[,] numbers = new int[countRaw, countColumn];
- for (int i = 0; i < countRaw; i++)
- {
- for (int j = 0; j < countColumn; j++)
- {
- numbers[i, j] = random.Next(minValue, maxValue + 1);
- }
- }
- int maxElement = numbers[0, 0];
- Console.WriteLine("Исходный массив: ");
- for (int i = 0;i < countRaw; i++)
- {
- for (int j = 0;j < countColumn; j++)
- {
- Console.Write(numbers[i, j] + " ");
- }
- Console.WriteLine();
- }
- for (int i = 0; i < countRaw; i++)
- {
- for (int j = 0; j <countColumn; j++)
- {
- if (numbers[i, j] > maxElement)
- {
- maxElement = numbers[i, j];
- }
- }
- }
- Console.WriteLine($"Наибольшие элемент массива: {maxElement}");
- for (int i = 0; i < countRaw; i++)
- {
- for (int j = 0; j < countColumn; j++)
- {
- if (numbers[i, j] == maxElement)
- {
- numbers[i, j] = changedValue;
- }
- }
- }
- Console.WriteLine("Модифицированный массив: ");
- for (int i = 0; i < countRaw; i++)
- {
- for (int j = 0; j < countColumn; j++)
- {
- Console.Write(numbers[i, j] + " ");
- }
- Console.WriteLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement