Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace C_sharp_Light
- {
- class Program
- {
- static void Main(string[] args)
- {
- int yOutput = 38;
- int[,] array = new int[10, 10];
- Random rand = new Random();
- Console.ForegroundColor = ConsoleColor.Yellow;
- for (int x = 0; x < array.GetLength(0); x++)
- {
- for (int y = 0; y < array.GetLength(1); y++)
- {
- array[x, y] = rand.Next(1, 100);
- if (array[x, y] >= 10)
- Console.Write(array[x, y] + " ");
- else
- Console.Write(array[x, y] + " ");
- }
- Console.WriteLine();
- }
- Console.ForegroundColor = ConsoleColor.White;
- int maxValue = 0;
- for (int x = 0; x < array.GetLength(0); x++)
- {
- for (int y = 0; y < array.GetLength(1); y++)
- {
- if (array[x, y] > maxValue)
- maxValue = array[x, y];
- }
- }
- for (int x = 0; x < array.GetLength(0); x++)
- {
- Console.SetCursorPosition(yOutput, x);
- for (int y = 0; y < array.GetLength(1); y++)
- {
- if (array[x, y] == maxValue)
- array[x, y] = 0;
- if (array[x, y] >= 10)
- {
- Console.ForegroundColor = ConsoleColor.Green;
- Console.Write(array[x, y] + " ");
- }
- else if (array[x, y] >= 1)
- {
- Console.ForegroundColor = ConsoleColor.Green;
- Console.Write(array[x, y] + " ");
- }
- else
- {
- Console.ForegroundColor = ConsoleColor.Red;
- Console.Write(array[x, y] + " ");
- }
- }
- }
- Console.ForegroundColor = ConsoleColor.White;
- Console.Write($"\n\nНаибольшие число = {maxValue}\n\n\n");
- Console.WriteLine("Жёлтый - изначальная матрица.\n" +
- "Зеленый - матрица после изменений\n" +
- "Красный - измененный элемент\n" +
- "Программа находит ВСЕ наибольшие числа в матрице\n");
- Console.ReadKey();
- }
- }
- }
Add Comment
Please, Sign In to add comment