Advertisement
TravaMan

Basic_Task13

Dec 8th, 2019
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.16 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Basic_Task13
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             const int SIZE = 10;
  10.             bool isFirst = true;
  11.             int[,] array = new int[SIZE, SIZE]{
  12.                 {1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
  13.                 {5, 3, 8, 4, 123, 453, 863, 23, 563, 12},
  14.                 {-5, -2, -10, 0, -34, -1000, -234, -5432, -67, -1},
  15.                 {3, 0, 8, 1, 1, 1, 2, 5, 3, 10},
  16.                 {3, 0, 8, 1, 1, 1, 2, 5, 3, 10},
  17.                 {3, 0, 8, 1, 1, 1, 2, 5, 3, 10},
  18.                 {3, 0, 8, 1, 1, 1, 2, 5, 3, 10},
  19.                 {3, 0, 8, 1, 1, 1, 2, 5, 3, 10},
  20.                 {3, 0, 8, 1, 1, 1, 2, 5, 3, 10},
  21.                 {3, 0, 8, 1, 1, 1, 2, 5, 3, 863}
  22.             };
  23.            
  24.             int max = array[0, 0];
  25.            
  26.             foreach (int i in array)  
  27.             {
  28.                 if (i > max)
  29.                 {
  30.                     max = i;
  31.                 }
  32.             }
  33.            
  34.             Console.WriteLine("Наибольший элемент: " + max);
  35.             Console.WriteLine();            
  36.             Console.WriteLine("Исходная матрица:");
  37.             for (int i = 0; i < SIZE; i++)
  38.             {
  39.                 for (int j = 0; j < SIZE; j++)
  40.                 {
  41.                     Console.Write(array[i,j] + " ");
  42.                 }
  43.                 Console.WriteLine();
  44.             }
  45.            
  46.             for (int i = 0; i < SIZE; i++)
  47.             {
  48.                 for (int j = 0; j < SIZE; j++)
  49.                 {
  50.                     if (max == array[i,j] && isFirst)
  51.                     {
  52.                         array[i,j] = 0;
  53.                         isFirst = false;
  54.                     }
  55.                 }
  56.             }
  57.             Console.WriteLine();
  58.             Console.WriteLine("Полученная матрицав:");
  59.             for (int i = 0; i < SIZE; i++)
  60.             {
  61.                 for (int j = 0; j < SIZE; j++)
  62.                 {
  63.                     Console.Write(array[i,j] + " ");
  64.                 }
  65.                 Console.WriteLine();
  66.             }
  67.         }
  68.     }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement