Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Homework21
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- int numberToReplace = 0;
- int maxElementMatrix = int.MinValue;
- int[,] array = new int[10, 10]
- {
- { 3,9,13,8,11,3,5,9,5,1},
- { 7,34,78,99,2,4,61,3,27,89},
- { 90,1,5,34,67,82,3,95,41,2},
- { 1,2,3,4,5,6,6,7,8,9},
- { 21,2,43,7,89,20,11,31,54,67 },
- { 9,5,7,22,34,5,66,78,9,2 },
- { 22,65,77,9,73,3,4,5,97,34 },
- { 44,3,9,87,6,55,25,3,1,77},
- { 3,22,11,32,45,69,89,4,7,41},
- { 11,3,44,76,54,43,4,99,12,32}
- };
- Console.WriteLine("Исходная матрица:");
- for (int i = 0; i < array.GetLength(0); i++)
- {
- for (int j = 0; j < array.GetLength(1); j++)
- {
- if (maxElementMatrix < array[i, j])
- {
- maxElementMatrix = array[i, j];
- }
- Console.Write(array[i, j] + " ");
- }
- Console.WriteLine();
- }
- Console.WriteLine($"\nМаксимальный элемент в матрице: {maxElementMatrix}.");
- Console.WriteLine("\nПолученная матрица:");
- for (int i = 0; i < array.GetLength(0); i++)
- {
- for (int j = 0; j < array.GetLength(1); j++)
- {
- if (array[i, j] == maxElementMatrix)
- {
- array[i, j] = numberToReplace;
- }
- Console.Write(array[i, j] + " ");
- }
- Console.WriteLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement