/
NikolayIvkin
/
TheAlgorithms
Обзор
Документация
Войти
/
NikolayIvkin
/
TheAlgorithms
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
src/main/java/com/thealgorithms/matrix/MirrorOfMatrix.java
36 строк
1 KB
varada610
Create package prime, matrix and games (#6139)
27 янв 2025, 14:10
Не верифицирован
27 янв 2025, 14:10
4ef0682
Код
Авторство
О чём код?
package com.thealgorithms.matrix; // Problem Statement import com.thealgorithms.matrix.utils.MatrixUtil; /* We have given an array of m x n (where m is the number of rows and n is the number of columns). Print the new matrix in such a way that the new matrix is the mirror image of the original matrix. The Original matrix is: | The Mirror matrix is: 1 2 3 | 3 2 1 4 5 6 | 6 5 4 7 8 9 | 9 8 7 @author - Aman (https://github.com/Aman28801) */ public final class MirrorOfMatrix { private MirrorOfMatrix() { } public static double[][] mirrorMatrix(final double[][] originalMatrix) { MatrixUtil.validateInputMatrix(originalMatrix); int numRows = originalMatrix.length; int numCols = originalMatrix[0].length; double[][] mirroredMatrix = new double[numRows][numCols]; for (int i = 0; i < numRows; i++) { mirroredMatrix[i] = MatrixUtil.reverseRow(originalMatrix[i]); } return mirroredMatrix; } }