Advertisement
RedFlys

HomeWork16. Max value

Aug 26th, 2020 (edited)
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.35 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp16.MaxValue
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int[,] array = new int[10, 10];
  10.             Random rand = new Random();
  11.             int maxValue = 0;
  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(10, 100);                    
  18.                     Console.Write(array[i, j] + " ");
  19.  
  20.                     if (maxValue < array[i,j])
  21.                     {
  22.                         maxValue = array[i, j];
  23.                     }
  24.                 }
  25.                 Console.WriteLine();
  26.             }
  27.  
  28.             Console.WriteLine($"\nМаксимальное значение: {maxValue}.\n");
  29.  
  30.             for (int i = 0; i < array.GetLength(0); i++)
  31.             {
  32.                 for (int j = 0; j < array.GetLength(1); j++)
  33.                 {      
  34.                     if (maxValue == array[i, j])
  35.                     {
  36.                         array[i, j] = 0;
  37.                         Console.Write(" ");
  38.                     }
  39.  
  40.                     Console.Write(array[i, j] + " ");
  41.                 }
  42.                 Console.WriteLine();
  43.             }
  44.  
  45.             Console.ReadKey();
  46.         }
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement