Advertisement
nikitaTheSlayer

Lesson: array2

Apr 11th, 2020
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.32 KB | None | 0 0
  1. using System;
  2.  
  3. namespace CSLight3
  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 maxElement = 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.                     if (maxElement < array[i, j])
  20.                     {
  21.                         maxElement = array[i, j];
  22.                     }
  23.                 }
  24.                 Console.WriteLine();
  25.             }
  26.  
  27.             Console.WriteLine("\n\nНовая матрица: ");
  28.             for (int i = 0; i < array.GetLength(0); i++)
  29.             {
  30.                 for (int j = 0; j < array.GetLength(1); j++)
  31.                 {
  32.                     if (array[i,j] == maxElement)
  33.                     {
  34.                         array[i, j] = 0;
  35.                     }
  36.                     Console.Write(array[i, j] + " ");
  37.                 }
  38.                 Console.WriteLine();
  39.             }
  40.  
  41.             Console.WriteLine("Наибольшее значение в матрице: " + maxElement);
  42.  
  43.         }
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement