Advertisement
Briotar

Homework 3

May 1st, 2021
107
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 Homework3
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int[,] matrix = new int[10, 10];
  10.             Random rand = new Random();
  11.             int max = int.MinValue;
  12.  
  13.             Console.WriteLine("Исходная матрица:");
  14.             for (int i = 0; i < matrix.GetLength(0); i++)
  15.             {
  16.                 for (int j = 0; j < matrix.GetLength(1); j++)
  17.                 {
  18.                     matrix[i, j] = rand.Next(0, 101);
  19.                     if (matrix[i,j] > max)
  20.                     {
  21.                         max = matrix[i, j];
  22.                     }
  23.                     Console.Write(matrix[i, j] + "\t");
  24.                 }
  25.                 Console.WriteLine();
  26.             }
  27.  
  28.             Console.WriteLine($"Максимальное значение - {max}");
  29.             Console.WriteLine("Новая матрица:");
  30.  
  31.             for (int i = 0; i < matrix.GetLength(0); i++)
  32.             {
  33.                 for (int j = 0; j < matrix.GetLength(1); j++)
  34.                 {
  35.                     if (matrix[i, j] == max)
  36.                     {
  37.                         matrix[i, j] = 0;
  38.                     }
  39.                     Console.Write(matrix[i, j] + "\t");
  40.                 }
  41.                 Console.WriteLine();
  42.             }
  43.         }
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement