/
ket12werw
/
Matrix
Обзор
Документация
Войти
/
ket12werw
/
Matrix
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
Matrix.java
54 строки
1 KB
ket12werw
create: Matrix.java
27 май 2026, 13:43
Верифицирован
27 май 2026, 13:43
fe492bc
Код
Авторство
О чём код?
import java.util.Random; public class Matrix { public static final int SIZE = 8; static void main() { int[][] originalMatrix = createMatrix(SIZE); System.out.println("Оригинальная матрица"); printMatrix(originalMatrix); System.out.println("Повернутая матрица"); int[][] rotatedMatrix = rotateMatrix(originalMatrix); printMatrix(rotatedMatrix); } private static int[][] rotateMatrix(int[][] original) { int size = original.length; int[][] result = new int[size][size]; for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { result[i][j] = original[size - 1 - j][i]; } } return result; } private static int[][] createMatrix(int size) { int[][] colors = new int[size][size]; Random random = new Random(); for (int i = 0; i < colors.length; i++) { for (int j = 0; j < colors[i].length; j++) { colors[i][j] = random.nextInt(256); } } return colors; } private static void printMatrix(int[][] colors) { for (int i = 0; i < colors.length; i++) { for (int j = 0; j < colors[i].length; j++) { System.out.format("%4d", colors[i][j]); } System.out.println(); } } }