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[] tempArray = 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];
- tempArray[0] = i;
- tempArray[1] = j;
- }
- }
- }
- for (int i = 0; i < array.GetLength(0); i++)
- {
- for (int j = 0; j < array.GetLength(1); j++)
- {
- if (tempArray[0] == i && tempArray[1] == j)
- {
- array[i, j] = 0;
- }
- }
- }
- Console.WriteLine("Измененная матрица:");
- for (int i = 0; i < array.GetLength(0); i++)
- {
- for (int j = 0; j < array.GetLength(1); j++)
- {
- Console.Write(array[i, j] + " ");
- }
- Console.WriteLine();
- }
- Console.Write("Максимально число - " + maxValue + " Находится по приведенным к нормальному виду координатам: " + (tempArray[0] + 1) + " | " + (tempArray[1] + 1));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement