Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Largest_Matrix_Element
- {
- class Program
- {
- private const string
- InitialArray = "Матрица: ",
- MaxElement = "Максимальный элимент: ",
- ResultMatrix = "Матрица без Максимума: ",
- EmptySpace = " ";
- private const int Min = 1, Max = 20, MatrixSize = 10;
- static void Main(string[] args)
- {
- int[,] matrix = new int[MatrixSize, MatrixSize];
- int maxI = 0, maxJ = 0;
- Random random = new Random();
- Console.WriteLine(InitialArray);
- for (int i = 0; i < MatrixSize; i++)
- {
- for (int j = 0; j < MatrixSize; j++)
- {
- matrix[i, j] = random.Next(Min, Max);
- Console.Write(matrix[i, j] + EmptySpace);
- if (matrix[maxI, maxJ] < matrix[i, j])
- {
- maxI = i;
- maxJ = j;
- }
- }
- Console.WriteLine();
- }
- Console.WriteLine();
- Console.WriteLine(MaxElement);
- Console.WriteLine(matrix[maxI, maxJ]);
- Console.WriteLine();
- Console.WriteLine(ResultMatrix);
- matrix[maxI, maxJ] = 0;
- for (int i = 0; i < MatrixSize; i++)
- {
- for (int j = 0; j < MatrixSize; j++)
- {
- Console.Write(matrix[i, j] + EmptySpace);
- }
- Console.WriteLine();
- }
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment