Matrix 90 Grad drehen
-
Does anyone know a better algorithm to turn a matrix by 90 degrees.
public class TurnMatrix { final int[][] mat = new int[][]{{1,2,3},{4,5,6},{7,8,9}}; int[][] matNew = new int[3][3]; public void turnMatrix90() { for(int i=0,k=2;i<3;i++,k--) { for(int j =0;j<3;j++) { matNew[j][k]=mat[i][j]; } } // print matNew }