Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class MainClass
- {
- public static void Main(string[] args)
- {
- int[,] matrix = new int[10, 10];
- int max = 0;
- Random rnd = new Random();
- Console.WriteLine("Исходная матрица\n");
- for (int x = 0; x < matrix.GetLength(0); x++)
- {
- for (int y = 0; y < matrix.GetLength(1); y++)
- {
- matrix[x, y] = rnd.Next(1, 100);
- if (matrix[x, y] < 10)
- {
- Console.Write(" " + matrix[x, y] + " ");
- }
- else
- {
- Console.Write(matrix[x, y] + " ");
- }
- }
- Console.WriteLine();
- }
- for (int x = 0; x < matrix.GetLength(0); x++)
- {
- for (int y = 0; y < matrix.GetLength(1); y++)
- {
- if (max < matrix[x, y])
- {
- max = matrix[x, y];
- }
- }
- }
- Console.WriteLine("\nМаксимальный элемент = " + max);
- Console.WriteLine("Получена матрица\n");
- for (int x = 0; x < matrix.GetLength(0); x++)
- {
- for (int y = 0; y < matrix.GetLength(1); y++)
- {
- if (matrix[x, y] == max)
- {
- matrix[x, y] = 0;
- }
- if (matrix[x, y] < 10)
- {
- Console.Write(" " + matrix[x, y] + " ");
- }
- else
- {
- Console.Write(matrix[x, y] + " ");
- }
- }
- Console.WriteLine();
- }
- Console.ReadKey();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement