Advertisement
dxoraxs

Untitled

Apr 12th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.90 KB | None | 0 0
  1. using System;
  2.  
  3. namespace homework
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             Random rand = new Random();
  10.             int[,] A = {
  11.             {0,0,0,0,0,0,0,0,0,0, },
  12.             {0,0,0,0,0,0,0,0,0,0, },
  13.             {0,0,0,0,0,0,0,0,0,0, },
  14.             {0,0,0,0,0,0,0,0,0,0, },
  15.             {0,0,0,0,0,0,0,0,0,0, },
  16.             {0,0,0,0,0,0,0,0,0,0, },
  17.             {0,0,0,0,0,0,0,0,0,0, },
  18.             {0,0,0,0,0,0,0,0,0,0, },
  19.             {0,0,0,0,0,0,0,0,0,0, },
  20.             {0,0,0,0,0,0,0,0,0,0, },
  21.             };
  22.             Console.WriteLine("Исходная матрица:");
  23.             for (int i=0; i< A.GetLength(0);i++)
  24.             {
  25.                 for (int j=0; j< A.GetLength(1);j++)
  26.                 {
  27.                     A[i,j]=rand.Next(10, 100);
  28.                     Console.Write(A[i, j]+" ");
  29.                 }
  30.                 Console.WriteLine();
  31.             }
  32.             int maxValue = int.MinValue;
  33.             int[] coor = new int[2];
  34.             for (int i=0; i< A.GetLength(0);i++)
  35.             {
  36.                 for (int j=0; j< A.GetLength(1);j++)
  37.                 {
  38.                     if (A[i, j] > maxValue)
  39.                     {
  40.                         maxValue = A[i, j];
  41.                         coor[0] = i;
  42.                         coor[1] = j;
  43.                     }
  44.                 }
  45.             }
  46.             A[coor[0], coor[1]] = 0;
  47.             Console.WriteLine("\nМаксимальное значение в матрице = "+maxValue);
  48.             Console.WriteLine("\nПолученная матрица: ");
  49.            
  50.             for (int i = 0; i < A.GetLength(0); i++)
  51.             {
  52.                 for (int j = 0; j < A.GetLength(1); j++)
  53.                 {
  54.                     Console.Write(A[i, j] + " ");
  55.                 }
  56.                 Console.WriteLine();
  57.             }
  58.         }
  59.     }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement