Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Advanced;
- import java.lang.reflect.Array;
- import java.util.*;
- public class array_temp {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String[] input = scanner.nextLine().split("\\(");
- int degrees = Integer.parseInt(input[1].substring(0, input[1].length() - 1));
- String command = scanner.nextLine();
- List<String> word = new ArrayList<>();
- int length = -1;
- while (!command.equals("END")) {
- word.add(command);
- int tempLength = command.length();
- if (tempLength > length) {
- length = tempLength;
- }
- command = scanner.nextLine();
- }
- int row = word.size();
- String[][] matrix = new String[row][];
- for (int i = 0; i < row; i++) {
- String[] tokens = word.get(i).split("");
- matrix[i] = tokens;
- }
- int numRotate = 0;
- int count = 0;
- if (degrees / 90 > 0) {
- for (int i = 0; i < degrees / 90; i++) {
- if (count >= 3) {
- count = 0;
- } else {
- count++;
- }
- }
- }
- if (count == 1) {
- ifRotate90(matrix, length);
- } else if (count == 2) {
- ifRotate180(matrix, length);
- } else if (count == 3) {
- ifRotate270(matrix, length);
- } else {
- for (int i = 0; i < row; i++) {
- for (int j = 0; j < length; j++) {
- try {
- System.out.print(matrix[i][j]);
- } catch (ArrayIndexOutOfBoundsException e) {
- System.out.print(" ");
- }
- }
- System.out.println();
- }
- }
- //---------
- }
- private static void ifRotate180(String[][] matrix, int length) {
- for (int i = matrix.length - 1; i >= 0; i--) {
- for (int j = length - 1; j >= 0; j--) {
- try {
- System.out.print(matrix[i][j]);
- } catch (ArrayIndexOutOfBoundsException e) {
- System.out.print(" ");
- }
- }
- System.out.println();
- }
- }
- private static void ifRotate270(String[][] matrix, int length) {
- for (int j = length - 1; j >= 0; j--) {
- for (int i = 0; i < matrix.length; i++) {
- try {
- System.out.print(matrix[i][j]);
- } catch (ArrayIndexOutOfBoundsException e) {
- System.out.print(" ");
- }
- }
- System.out.println();
- }
- }
- private static void ifRotate90(String[][] matrix, int length) {
- for (int j = 0; j < length; j++) {
- for (int i = matrix.length - 1; i >= 0; i--) {
- try {
- System.out.print(matrix[i][j]);
- } catch (ArrayIndexOutOfBoundsException e) {
- System.out.print(" ");
- }
- }
- System.out.println();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement