Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ConsoleApp9
- {
- class Program
- {
- static void Main(string[] args)
- {
- int greatestNumber = 0;
- Random rand = new Random();
- int[,] array = new int[10, 10];
- for (int i = 0; i < array.GetLength(0); i++)
- {
- for (int j = 0; j < array.GetLength(1); j++)
- {
- array[i, j] = rand.Next(0, 10);
- }
- }
- for (int i = 0; i < array.GetLength(0); i++)
- {
- for (int j = 0; j < array.GetLength(1); j++)
- {
- if (greatestNumber <= array[i, j])
- {
- greatestNumber = array[i, j];
- }
- }
- }
- 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();
- }
- Console.WriteLine($"\nНаибольшее число было: {greatestNumber}\nНаибольшие число в матрице заменено на ноль:");
- for (int i = 0; i < array.GetLength(0); i++)
- {
- for (int j = 0; j < array.GetLength(1); j++)
- {
- if (array[i, j] == greatestNumber)
- {
- Console.ForegroundColor = ConsoleColor.Red;
- array[i, j] = 0;
- }
- Console.Write($"{array[i, j]} ");
- Console.ResetColor();
- }
- Console.WriteLine();
- }
- Console.ReadKey();
- }
- }
- }
Add Comment
Please, Sign In to add comment