Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Random random = new Random();
- int maxNumber = int.MinValue;
- int setNumber = 0;
- int maxRandomNumber = 5;
- int minRandomNumber = 1;
- int matrixLineIndex = 10;
- int matrixColumnIndex = 10;
- int[,] matrix = new int[matrixLineIndex, matrixColumnIndex];
- for (int i = 0; i < matrix.GetLength(0); i++)
- {
- for (int j = 0; j < matrix.GetLength(1); j++)
- {
- matrix[i, j] = random.Next(minRandomNumber, maxRandomNumber + 1);
- if (maxNumber < matrix[i, j])
- {
- maxNumber = matrix[i, j];
- }
- Console.Write(matrix[i, j] + " ");
- }
- Console.WriteLine();
- }
- Console.WriteLine();
- for (int i = 0; i < matrix.GetLength(0); i++)
- {
- for (int j = 0; j < matrix.GetLength(1); j++)
- {
- if (maxNumber == matrix[i, j])
- {
- matrix[i, j] = setNumber;
- }
- Console.Write(matrix[i, j] + " ");
- }
- Console.WriteLine();
- }
- Console.WriteLine($"\nНаибольший элемент матрицы: {maxNumber} \n");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement