Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Test
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[,] array = new int[10,10];
- Random rand = new Random();
- int maxElement = int.MinValue;
- for(int i = 0; i < array.GetLength(0); i++)
- {
- for(int j = 0; j < array.GetLength(1); j++)
- {
- array[i, j] = rand.Next(1, 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 (maxElement < array[i, j])
- {
- maxElement = array[i, j];
- }
- }
- }
- Console.WriteLine($"\nMax Element: {maxElement}\n");
- for (int i = 0; i < array.GetLength(0); i++)
- {
- for (int j = 0; j < array.GetLength(1); j++)
- {
- if (maxElement == array[i, j])
- {
- array[i,j] = 0;
- }
- }
- }
- 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();
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment