JAVA-Aufgaben/src/com/company/jvaBasics/Rotieren.java
2020-11-25 21:45:06 +01:00

38 lines
1005 B
Java

package com.company.jvaBasics;
public class Rotieren {
public static void main(String[] args) {
boolean[][] rotate = {
{true, false, false},
{false, true, false},
{false, false, true},
{false, false, false}
};
boolean[][] ausgabe = negativeRotation(rotate);
for (int i = 0; i < ausgabe.length; i++) {
for (int j = 0; j < ausgabe[0].length; j++) {
System.out.print(ausgabe[i][j] + " ");
}
System.out.println();
}
}
public static boolean[][] negativeRotation(boolean[][] rotating) {
boolean[][] arrayCopy;
arrayCopy = new boolean[rotating[0].length][rotating.length];
for (int i = 0; i < arrayCopy.length; i++) {
for (int j = 0; j < arrayCopy[0].length; j++) {
arrayCopy[i][j] = rotating[j][rotating[j].length - i - 1];
}
}
return arrayCopy;
}
}