/
weazweazweaz
/
hwarrays
Обзор
Документация
Войти
/
weazweazweaz
/
hwarrays
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
MultidimensionalArrays.java
38 строк
1 KB
weazweazweaz
upload files
18 ноя 2025, 17:54
18 ноя 2025, 17:54
803afa5
Код
Авторство
О чём код?
import java.util.Arrays; import java.util.Random; public class MultidimensionalArrays { public static final int SIZE = 8; public static void main(String[] args) { int[][] colors = new int[SIZE][SIZE]; Random random = new Random(); for (int i = 0; i < SIZE; i++) { for (int j = 0; j < SIZE; j++) { colors[i][j] = random.nextInt(256); } } System.out.println("Исходная матрица: "); printMatrix(colors); int[][] rotatedColors = new int[SIZE][SIZE]; for (int i = 0; i < SIZE; i++) { for (int j = 0; j < SIZE; j++) { rotatedColors[i][j] = colors[SIZE - 1 - j][i]; } } System.out.println("\n Результат: "); printMatrix(rotatedColors); } public static void printMatrix(int[][] matrix) { for (int i = 0; i < SIZE; i++) { for (int j = 0; j < SIZE; j++) { System.out.format("%4d", matrix[i][j]);; } System.out.println(); } } }