Anonim_999

Untitled

Jan 9th, 2021 (edited)
807
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.85 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp9
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int greatestNumber = 0;
  10.             Random rand = new Random();
  11.             int[,] array = new int[10, 10];
  12.  
  13.             for (int i = 0; i < array.GetLength(0); i++)
  14.             {
  15.                 for (int j = 0; j < array.GetLength(1); j++)
  16.                 {
  17.                     array[i, j] = rand.Next(0, 10);
  18.                 }
  19.             }
  20.  
  21.             for (int i = 0; i < array.GetLength(0); i++)
  22.             {
  23.                 for (int j = 0; j < array.GetLength(1); j++)
  24.                 {
  25.                     if (greatestNumber <= array[i, j])
  26.                     {
  27.                         greatestNumber = array[i, j];
  28.                     }
  29.                 }
  30.             }
  31.  
  32.             for (int i = 0; i < array.GetLength(0); i++)
  33.             {
  34.                 for (int j = 0; j < array.GetLength(1); j++)
  35.                 {
  36.                     Console.Write($"{array[i, j]} ");
  37.                 }
  38.                 Console.WriteLine();
  39.             }
  40.  
  41.             Console.WriteLine($"\nНаибольшее число было: {greatestNumber}\nНаибольшие число в матрице заменено на ноль:");
  42.  
  43.             for (int i = 0; i < array.GetLength(0); i++)
  44.             {
  45.                 for (int j = 0; j < array.GetLength(1); j++)
  46.                 {
  47.                     if (array[i, j] == greatestNumber)
  48.                     {
  49.                         Console.ForegroundColor = ConsoleColor.Red;
  50.                         array[i, j] = 0;
  51.                     }
  52.                     Console.Write($"{array[i, j]} ");
  53.                     Console.ResetColor();
  54.                 }
  55.                 Console.WriteLine();
  56.             }
  57.  
  58.             Console.ReadKey();
  59.         }
  60.     }
  61. }
Add Comment
Please, Sign In to add comment