Advertisement
DrDemonik

Untitled

Mar 13th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.55 KB | None | 0 0
  1. int[,] a = new int[10,10];
  2.             Random rand = new Random();
  3.  
  4.             for (int i = 0; i < a.GetLength(0); i++)
  5.             {
  6.                 for (int j=0; j < a.GetLength(1);j++)
  7.                 {
  8.                     a[i, j] = rand.Next(0,100);
  9.                 }
  10.             }
  11.  
  12.             int max = a[0,0], maxI=0, maxJ=0;
  13.  
  14.             for (int i = 0; i < a.GetLength(0); i++)
  15.             {
  16.                 for (int j = 0; j < a.GetLength(1); j++)
  17.                 {  
  18.                     if(max< a[i, j])
  19.                     {
  20.                         max = a[i, j];
  21.                         maxI = i;
  22.                         maxJ = j;
  23.                     }                    
  24.                 }
  25.             }
  26.  
  27.             Console.WriteLine("Исходная матрица");
  28.             for(int i = 0; i < a.GetLength(0); i++)
  29.             {
  30.                 for (int j = 0; j < a.GetLength(1); j++)
  31.                 {
  32.                     Console.Write(a[i, j]+" ");
  33.                 }
  34.                 Console.Write("\n");
  35.             }
  36.             Console.WriteLine("Максимальное число = " + max);
  37.  
  38.             Console.WriteLine("Текущая матрица");
  39.             for (int i = 0; i < a.GetLength(0); i++)
  40.             {
  41.                 for (int j = 0; j < a.GetLength(1); j++)
  42.                 {
  43.                     if (maxI == i && maxJ == j)
  44.                         Console.Write(0 + " ");
  45.                     Console.Write(a[i, j] + " ");
  46.                 }
  47.                 Console.Write("\n");
  48.             }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement