W1thr

Массивы - 2

Feb 6th, 2021 (edited)
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.13 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Homework2
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             Random rand = new Random();
  10.             int[,] array = new int[10, 10];
  11.             int maxValue = int.MinValue;
  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 (array[i, j] > maxValue)
  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 (array[i, j] == maxValue) array[i, j] = 0;
  35.                     Console.Write(array[i, j] + " ");
  36.                 }
  37.                 Console.WriteLine();
  38.             }
  39.         }
  40.     }
  41. }
  42.  
Add Comment
Please, Sign In to add comment