Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace MaxElement
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[,] array = new int[10, 10];
- int maxValue = int.MinValue;
- int[] coordinate = new int[2];
- Random rand = new Random();
- Console.WriteLine("Начальная матрица:");
- for (int i = 0; i < array.GetLength(0); i++)
- {
- for (int j = 0; j < array.GetLength(1); j++)
- {
- array[i, j] = rand.Next(0, 100);
- Console.Write(array[i, j] + " ");
- }
- Console.WriteLine();
- }
- for (int i = 0; i < array.GetLength(0); i++)
- {
- for (int j = 0; j < array.GetLength(1); j++)
- {
- if (maxValue < array[i, j])
- {
- maxValue = array[i, j];
- coordinate[0] = i;
- coordinate[1] = j;
- }
- }
- }
- Console.WriteLine("Измененная матрица:");
- for (int i = 0; i < array.GetLength(0); i++)
- {
- for (int j = 0; j < array.GetLength(1); j++)
- {
- if (coordinate[0] == i && coordinate[1] == j)
- {
- array[i, j] = 0;
- }
- Console.Write(array[i, j] + " ");
- }
- Console.WriteLine();
- }
- Console.Write("Максимально число - " + maxValue + ". координаты по которым находится измененное число " + coordinate[0] + " | " + coordinate[1]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement