SHOW:
|
|
- or go back to the newest paste.
1 | using System; | |
2 | ||
3 | namespace C_sharp_Light | |
4 | { | |
5 | class Program | |
6 | { | |
7 | static void Main(string[] args) | |
8 | { | |
9 | int yOutput = 38; | |
10 | int[,] array = new int[10, 10]; | |
11 | Random rand = new Random(); | |
12 | ||
13 | Console.ForegroundColor = ConsoleColor.Yellow; | |
14 | for (int x = 0; x < array.GetLength(0); x++) | |
15 | { | |
16 | for (int y = 0; y < array.GetLength(1); y++) | |
17 | { | |
18 | array[x, y] = rand.Next(1, 100); | |
19 | if (array[x, y] >= 10) | |
20 | Console.Write(array[x, y] + " "); | |
21 | else | |
22 | Console.Write(array[x, y] + " "); | |
23 | } | |
24 | Console.WriteLine(); | |
25 | } | |
26 | Console.ForegroundColor = ConsoleColor.White; | |
27 | ||
28 | ||
29 | int maxValue = 0; | |
30 | for (int x = 0; x < array.GetLength(0); x++) | |
31 | { | |
32 | for (int y = 0; y < array.GetLength(1); y++) | |
33 | { | |
34 | if (array[x, y] > maxValue) | |
35 | maxValue = array[x, y]; | |
36 | } | |
37 | } | |
38 | for (int x = 0; x < array.GetLength(0); x++) | |
39 | { | |
40 | Console.SetCursorPosition(yOutput, x); | |
41 | for (int y = 0; y < array.GetLength(1); y++) | |
42 | { | |
43 | if (array[x, y] == maxValue) | |
44 | array[x, y] = 0; | |
45 | if (array[x, y] >= 10) | |
46 | { | |
47 | Console.ForegroundColor = ConsoleColor.Green; | |
48 | Console.Write(array[x, y] + " "); | |
49 | } | |
50 | else if (array[x, y] >= 1) | |
51 | { | |
52 | Console.ForegroundColor = ConsoleColor.Green; | |
53 | Console.Write(array[x, y] + " "); | |
54 | } | |
55 | else | |
56 | { | |
57 | Console.ForegroundColor = ConsoleColor.Red; | |
58 | Console.Write(array[x, y] + " "); | |
59 | } | |
60 | } | |
61 | } | |
62 | Console.ForegroundColor = ConsoleColor.White; | |
63 | Console.Write($"\n\nНаибольшие число = {maxValue}\n\n\n"); | |
64 | Console.WriteLine("Жёлтый - изначальная матрица.\n" + | |
65 | "Зеленый - матрица после изменений\n" + | |
66 | "Красный - измененный элемент\n" + | |
67 | "Программа находит ВСЕ наибольшие числа в матрице\n"); | |
68 | ||
69 | Console.ReadKey(); | |
70 | } | |
71 | } | |
72 | } |