Advertisement
CrewLab

day 03_4

May 19th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.81 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 Les3
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int max_int = 0;
  14.             int[,] arr =
  15.             {
  16.                 {4, 5, 3, 5, 7, 8, 1, 4, 1, 0 },
  17.                 {1, 8, 7, 4, 2, 4, 2, 7, 8, 1 },
  18.                 {2, 4, 0, 1, 5, 4, 7, 2, 1, 0 },
  19.                 {1, 5, 3, 2, 7, 4, 6, 2, 1, 1 },
  20.                 {2, 7, 2, 3, 1, 2, 4, 5, 6, 2 },
  21.                 {3, 1, 5, 2, 1, 2, 6, 8, 1, 2 },
  22.                 {2, 4, 1, 7, 5, 4, 7, 3, 1, 0 },
  23.                 {3, 4, 2, 6, 7, 7, 1, 4, 2, 1 },
  24.                 {1, 5, 1, 0, 6, 3, 8, 1, 2, 1 },
  25.                 {3, 6, 1, 4, 2, 3, 3, 6, 5, 3 }
  26.             };
  27.             Console.WriteLine("Исходная матрица:");
  28.             for (int i = 0; i < arr.GetLength(0); i++)
  29.             {
  30.                 for (int j = 0; j < arr.GetLength(1); j++)
  31.                 {
  32.                     Console.Write(arr[i, j] + " ");
  33.                     if (arr[i, j] > max_int)
  34.                         max_int = arr[i, j];
  35.  
  36.                 }
  37.                 Console.WriteLine();
  38.             }
  39.             Console.WriteLine();
  40.             Console.WriteLine("Наибольший элемент: " + max_int);
  41.             Console.WriteLine("\nПолученная матрица:");
  42.             for (int i = 0; i < arr.GetLength(0); i++)
  43.             {
  44.                 for (int j = 0; j < arr.GetLength(1); j++)
  45.                 {
  46.                     if (arr[i, j] == max_int)
  47.                         arr[i, j] = 0;
  48.                     Console.Write(arr[i, j] + " ");
  49.                 }
  50.                 Console.WriteLine();
  51.             }
  52.             Console.WriteLine();
  53.         }
  54.     }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement