2차원 배열 90도 회전 공식

이형석·2024년 4월 16일

알고리즘 Phase1

목록 보기
18/59

2차원 배열을 90도 회전 하는 공식

n-j-1 을 기억하자

int n;
int[][] arr = new int[n][n];
int[][] tmp = new int[n][n];

for(int i = 0; i < n; i++){
	for(int j = 0; j < n; j++){
    	tmp[i][j] = arr[n-j-1][i];
	}
}
profile
금융IT 개발자

0개의 댓글