https://swexpertacademy.com/main/solvingProblem/solvingProblem.do
SW Expert Academy
SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!
swexpertacademy.com
2차원 배열 for문 연습문제? 같은 느낌이었다. 공식이 그렇게 어렵진 않았다!
핵심 코드는 아래 3줄이다
map90[j][n-1 - i] = map[i][j];
map180[n-1 - i][n-1 - j] = map[i][j];
map270[n-1 - j][i] = map[i][j];
#include <iostream>
using namespace std;
#define MAX 8
int main(int argc, char** argv)
{
int T;
cin >> T;
for(int t=0;t<T;t++){
int n;
int sum = 0;
cin >> n;
int map[MAX][MAX] = {0,};
int map90[MAX][MAX] = {0,};
int map180[MAX][MAX] = {0,};
int map270[MAX][MAX] = {0,};
for(int i=0;i<n;i++)for(int j=0;j<n;j++) cin >> map[i][j];
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
map90[j][n-1 - i] = map[i][j];
map180[n-1 - i][n-1 - j] = map[i][j];
map270[n-1 - j][i] = map[i][j];
}
}
cout << "#" << t+1 << "\n";
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
cout << map90[i][j];
}
cout <<" ";
for(int j=0;j<n;j++){
cout << map180[i][j];
}
cout <<" ";
for(int j=0;j<n;j++){
cout << map270[i][j];
}
cout << "\n";
}
}
return 0;
}
'코딩테스트 연습 > SWEA' 카테고리의 다른 글
[SWEA] 1959. 두 개의 숫자열 D2 (c++) (0) | 2022.05.25 |
---|---|
[SWEA] 1983. 조교의 성적 매기기 D2 (c++) (0) | 2022.05.24 |
[SWEA] 1974. 스도쿠 검증 d2 (c++) (0) | 2022.05.23 |
[SWEA] 1954. 달팽이 숫자 d2 (c++) (0) | 2022.05.23 |
[SWEA] 1204. [S/W 문제해결 기본] 1일차 - 최빈수 구하기 D2 (0) | 2022.05.23 |