/
Arsalan
/
massivMulti
Обзор
Документация
Войти
/
Arsalan
/
massivMulti
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
Main.java
62 строки
2 KB
Arsalan
upload files
14 авг 2025, 16:06
14 авг 2025, 16:06
d3189a4
Код
Авторство
О чём код?
import java.util.Random; import java.util.Scanner; public class Main { public static final int SIZE = 8; public static void main(String[] args) { int[][] arr = new int[SIZE][SIZE]; Random random = new Random(); for (int i = 0; i < SIZE; i++) { for (int j = 0; j < SIZE; j++) { arr[i][j] = random.nextInt(256); } } printArray(arr); System.out.println(); Scanner scanner = new Scanner(System.in); System.out.println("Введите угол поворота (возможные значения 90, 180, 270): "); int angle = scanner.nextInt(); switch (angle) { case 90: arr = rotateArray(arr); break; case 180: arr = rotateArray(arr); arr = rotateArray(arr); break; case 270: arr = rotateArray(arr); arr = rotateArray(arr); arr = rotateArray(arr); break; } printArray(arr); } public static void printArray(int[][] arr) { for (int i = 0; i < SIZE; i++) { for (int j = 0; j < SIZE; j++) { System.out.print(arr[i][j] + " "); } System.out.println(); } } public static int[][] rotateArray(int[][] arr) { int[][] result = new int[SIZE][SIZE]; for (int i = 0; i < SIZE; i++) { for (int j = 0; j < SIZE; j++) { result[i][j] = arr[SIZE - j - 1][i]; } } return result; } }