회전 규칙만 찾으면 됨!
180도, 270도는 90도 회전을 반복
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
int main() {
int test_case;
int T;
cin >> T;
for (test_case = 1; test_case <= T; ++test_case) {
int N, tmp;
int arr[7][7] = { 0, };
int arr_90[7][7] = { 0, };
int arr_180[7][7] = { 0, };
int arr_270[7][7] = { 0, };
cin >> N;
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
cin >> tmp;
arr[i][j] = tmp;
}
}
//90도 회전
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
arr_90[j][(N - 1) - i] = arr[i][j];
}
}
//180도 회전
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
arr_180[j][(N - 1) - i] = arr_90[i][j];
}
}
//270도 회전
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
arr_270[j][(N - 1) - i] = arr_180[i][j];
}
}
cout << "#" << test_case << endl;
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
cout << arr_90[i][j];
}
cout << " ";
for (int j = 0; j < N; j++) {
cout << arr_180[i][j];
}
cout << " ";
for (int j = 0; j < N; j++) {
cout << arr_270[i][j];
}
cout << endl;
}
}
return 0;
}