kwest87

Untitled

Mar 28th, 2022
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.73 KB | None | 0 0
  1. [StartCode]
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7.  
  8. namespace ConsoleApp2
  9. {
  10.     internal class Program
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             int[,] slot = new int[10,10];
  15.             int maxSlot = 0;
  16.             int zeroSlot = 0;
  17.             Random random = new Random();
  18.  
  19.             Console.WriteLine("Изначальная матрица : ");
  20.  
  21.             for (int i = 0; i < slot.GetLength(0); i++)
  22.             {
  23.  
  24.                 for (int j = 0; j < slot.GetLength(1); j++)
  25.                 {
  26.                     Console.Write((slot[i, j]=random.Next(1,10)) + " ");
  27.                    
  28.                     if(slot[i, j] > maxSlot)
  29.                     {
  30.                         maxSlot = slot[i, j];
  31.                     }
  32.                 }
  33.                 Console.WriteLine();
  34.             }
  35.             Console.WriteLine("Максимальное число в матрице : " + maxSlot);
  36.            
  37.             for (int i = 0; i < slot.GetLength(0); i++)
  38.             {
  39.  
  40.                 for (int j = 0; j < slot.GetLength(1); j++)
  41.                 {
  42.  
  43.                     if(slot[i, j] == maxSlot)
  44.                     {
  45.                         slot[i, j] = zeroSlot;
  46.                     }
  47.                 }
  48.             }
  49.             Console.WriteLine("Изменённая матрица : ");
  50.  
  51.             for (int i = 0; i < slot.GetLength(0); i++)
  52.             {
  53.  
  54.                 for (int j = 0; j < slot.GetLength(1); j++)
  55.                 {
  56.                     Console.Write((slot[i, j]) + " ");
  57.                 }
  58.                 Console.WriteLine();
  59.             }
  60.         }
  61.     }
  62. }
  63. [EndCode]
Advertisement
Add Comment
Please, Sign In to add comment