package oSWExpertAcademy;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class D2_1961 {
//90도 회전하는 static 메서드 생성
static int[][] rotate(int[][] arr){
int N = arr.length;
int[][] rotate = new int[N][N];
for(int i=0; i<rotate.length; i++) {
for(int j=0; j<rotate.length; j++) {
rotate[i][j] = arr[N-1-j][i];
}
}
return rotate;
}
public static void main(String[]args) {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
try {
int testCase = Integer.parseInt(br.readLine());
for(int tc=1; tc<=testCase; tc++) {
int N = Integer.parseInt(br.readLine());
int[][] arr = new int[N][N];
for(int i=0; i<N; i++) {
StringTokenizer st =new StringTokenizer(br.readLine());
for(int j=0; j<N; j++) {
arr[i][j] = Integer.parseInt(st.nextToken());
// System.out.print(arr[i][j]+" ");
}
//System.out.println();
}
//원본 배열을 90도 회전
int arrf[][] = rotate(arr);
//위의 배열을 90도 회전함으로 원본 배열의 180도 회전
int arrs[][] = rotate(arrf);
//270도 회전
int arrt[][] = rotate(arrs);
System.out.println("#"+tc);
//2중 배열을 이런식으로 돌려줌으로 90도 180도 270도 회전한 배열이 한번에 출력되게 해준
for(int i=0; i<N; i++) {
for(int j=0; j<N; j++) {
System.out.print(arrf[i][j]);
}
System.out.print(" ");
for(int j=0; j<N; j++) {
System.out.print(arrs[i][j]);
}
System.out.print(" ");
for(int j=0; j<N; j++) {
System.out.print(arrt[i][j]);
}
System.out.println();
}
}
} catch (NumberFormatException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
댓글