Advertisement
Guest User

Untitled

a guest
May 19th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.51 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 ConsoleApp3
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.  
  14.             int n = 10, maxValue = 0, toChangeX = 0, toChangeY = 0;
  15.             int[,] matrix1 = new int[n, n];
  16.             Random rand = new Random();
  17.  
  18.             for (int i = 0; i < matrix1.GetLength(0); i++)
  19.             {
  20.                 for (int j = 0; j < matrix1.GetLength(1); j++)
  21.                 {
  22.                     matrix1[i, j] = rand.Next(10, 100);
  23.                     Console.Write(matrix1[i, j] + " ");
  24.                     if (maxValue < matrix1[i, j])
  25.                     {
  26.                         maxValue = matrix1[i, j];
  27.                         toChangeX = j;
  28.                         toChangeY = i;
  29.                     }
  30.                 }
  31.                 Console.WriteLine();
  32.             }
  33.             Console.WriteLine();
  34.             Console.WriteLine();
  35.  
  36.             Console.WriteLine("Максимальное значение: " + maxValue);
  37.             matrix1[toChangeY, toChangeX] = 0;
  38.             Console.WriteLine();
  39.  
  40.             for (int i = 0; i < matrix1.GetLength(0); i++)
  41.             {
  42.                 for (int j = 0; j < matrix1.GetLength(1); j++)
  43.                 {
  44.                     Console.Write(matrix1[i, j] + " ");
  45.                 }
  46.                 Console.WriteLine();
  47.             }
  48.  
  49.             Console.ReadKey();
  50.  
  51.         }
  52.     }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement