Advertisement
SnowPhoenix347

Untitled

Oct 29th, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.64 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace FifthProject
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int max = 0;
  14.             int x, y;
  15.  
  16.             Random random = new Random();
  17.  
  18.             int[,] array = new int[10, 10];
  19.             for (int i = 0; i < array.GetLength(0); i++)
  20.                 for (int j = 0; j < array.GetLength(1); j++)
  21.                     array[i, j] = random.Next(0, 10);
  22.  
  23.             Console.Write("Матрица исходная: ");
  24.             for (int i = 0; i < array.GetLength(0); i++)
  25.             {
  26.                 for (int j = 0; j < array.GetLength(1); j++)
  27.                 {
  28.                     Console.Write(array[i, j]);
  29.                 }
  30.                 Console.WriteLine();
  31.             }
  32.  
  33.             for (int i = 0; i < array.GetLength(0); i++)
  34.             {
  35.                 for (int j = 0; j < array.GetLength(1); j++)
  36.                 {
  37.                     if (max < array[i, j])
  38.                     {
  39.                         max = array[i, j];
  40.                         x = i;
  41.                         y = j;
  42.                         array[x, y] = 0;
  43.                     }
  44.                 }
  45.             }
  46.  
  47.             Console.Write("Матрица полученная: ");
  48.             for (int i = 0; i < array.GetLength(0); i++)
  49.             {
  50.                 for (int j = 0; j < array.GetLength(1); j++)
  51.                 {
  52.                     Console.Write(array[i, j]);
  53.                 }
  54.                 Console.WriteLine();
  55.             }
  56.         }
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement