Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace CSLightFirst
- {
- class Program
- {
- static void Main()
- {
- Random rand = new Random();
- int[,] data = new int[10, 10];
- int maxNumber = -1;
- int maxNumPositionX = -1;
- int maxNumPositionY = -1;
- Console.ForegroundColor = ConsoleColor.Blue;
- Console.WriteLine("Исходный массив:\n");
- Console.ForegroundColor = ConsoleColor.White;
- for (int i = 0; i < data.GetLength(0); i++)
- {
- for (int j = 0; j < data.GetLength(1); j++)
- {
- data[i, j] = rand.Next(1, 100);
- Console.Write(data[i, j] + " ");
- if (data[i, j] > maxNumber)
- {
- maxNumber = data[i, j];
- maxNumPositionY = i;
- maxNumPositionX = j;
- }
- }
- Console.WriteLine();
- }
- data[maxNumPositionY, maxNumPositionX] = 0;
- Console.ForegroundColor = ConsoleColor.Blue;
- Console.WriteLine("\nПолученный массив:\n");
- Console.ForegroundColor = ConsoleColor.White;
- for (int i = 0; i < data.GetLength(0); i++)
- {
- for (int j = 0; j < data.GetLength(1); j++)
- {
- Console.Write(data[i, j] + " ");
- }
- Console.WriteLine();
- }
- Console.ForegroundColor = ConsoleColor.Blue;
- Console.WriteLine("\nНаибольший элемент " +
- $"находится в позиции {maxNumPositionY} | {maxNumPositionX} и равен {maxNumber}");
- Console.ForegroundColor = ConsoleColor.White;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement