Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Homework_1
- {
- class Program
- {
- static void Main(string[] args)
- {
- int arrayXSize = 10;
- int arrayYSize = 10;
- int[,] array = new int[arrayXSize, arrayYSize];
- int maxArrayItem = int.MinValue;
- int countMaxArrayItem = 0;
- int changeMaxArrayItem = 0;
- Random random = new Random();
- Console.WriteLine("Матрица");
- for (int i = 0; i < array.GetLength(0); i++)
- {
- for (int j = 0; j < array.GetLength(1); j++)
- {
- array[i, j] = random.Next(10, 100);
- Console.Write(array[i, j] + " ");
- if (maxArrayItem <= array[i, j])
- {
- maxArrayItem = array[i, j];
- }
- }
- Console.WriteLine();
- }
- Console.WriteLine("\nОбработаная матрица");
- for (int i = 0; i < array.GetLength(0); i++)
- {
- for (int j = 0; j < array.GetLength(1); j++)
- {
- if (maxArrayItem == array[i, j])
- {
- countMaxArrayItem++;
- array[i, j] = changeMaxArrayItem;
- }
- Console.Write(array[i, j] + " ");
- }
- Console.WriteLine();
- }
- Console.WriteLine($"\nНаибольший элемент в матрице = {maxArrayItem} и он встречается {countMaxArrayItem} раз(а).");
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement