[SW1961] 숫자 배열 회전
✏️ 𝗔𝗹𝗴𝗼𝗿𝗶𝘁𝗵𝗺/SW Expert Academy

[SW1961] 숫자 배열 회전

 

 SW Expert Academy- 숫자 배열 회전 

문제 링크

https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV5Pq-OKAVYDFAUq&categoryId=AV5Pq-OKAVYDFAUq&categoryType=CODE&problemTitle=%EC%88%AB%EC%9E%90+%EB%B0%B0%EC%97%B4&orderBy=FIRST_REG_DATETIME&selectCodeLang=ALL&select-1=&pageSize=10&pageIndex=1&&&&&&&&& 

 

SW Expert Academy

SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!

swexpertacademy.com

 

문제 입력

더보기
10
3
1 2 3
4 5 6
7 8 9
6
6 9 4 7 0 5
8 9 9 2 6 5
6 8 5 4 9 8
2 2 7 7 8 4
7 5 1 9 7 9
8 9 3 9 7 6
7
9 3 1 8 5 0 5
1 1 1 7 9 1 8
3 6 1 4 7 7 4
3 1 8 5 3 0 7
2 5 2 5 7 6 8
2 8 5 2 6 7 0
0 5 5 9 3 6 0
3
6 0 4
7 9 3
8 1 2
6
1 6 4 0 8 1
0 8 0 4 1 2
7 7 6 8 4 3
8 6 3 8 0 0
5 7 7 7 6 4
9 1 8 1 7 1
3
4 1 9
9 9 7
8 0 1
5
1 0 2 2 7
5 2 4 8 5
4 7 8 2 3
9 6 2 8 5
9 6 1 6 6
3
4 8 3
4 6 3
3 9 6
3
4 9 7
0 1 3
4 4 3
5
1 1 7 4 1
0 7 9 3 5
5 2 5 8 6
6 1 9 0 6
7 0 1 3 9
#1
741 987 369 
852 654 258 
963 321 147 
#2
872686 679398 558496 
952899 979157 069877 
317594 487722 724799 
997427 894586 495713 
778960 562998 998259 
694855 507496 686278 
#3
0223319 0639550 5847800 
5851613 0762582 0170676 
5528111 8675252 5973763 
9255478 7035813 8745529 
3673795 4774163 1118255 
6760710 8197111 3161585 
0087485 5058139 9133220 
#4
876 218 432 
190 397 091 
234 406 678 
#5
958701 171819 123041 
176786 467775 814067 
873604 008368 048871 
178840 348677 406378 
760418 214080 687671 
140321 180461 107859 
#6
894 108 971 
091 799 190 
179 914 498 
#7
99451 66169 75356 
66720 58269 28286 
12842 32874 24821 
68282 58425 02766 
65357 72201 15499 
#8
344 693 336 
968 364 869 
633 384 443 
#9
404 344 733 
419 310 914 
337 794 404 
#10
76501 93107 15669 
01271 60916 43803 
19597 68525 79591 
30834 53970 17210 
96651 14711 10567

 

문제 풀이

package sw.expert.academy;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.Scanner;


public class SW1961숫자배열회전 {

	public static void main(String[] args) throws FileNotFoundException {
		System.setIn(new FileInputStream("src/sw/expert/academy/input.txt"));
		Scanner sc = new Scanner(System.in);

		// T 입력
		int T = sc.nextInt();
		for (int t = 0; t < T; t++) {
			int n = sc.nextInt();

			// 배열 입력 받기
			int[][] map = new int[n][n];
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					map[i][j] = sc.nextInt();
				}
			}

			// 90도
			int[][] map_90 = new int[n][n];
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					map_90[j][n - 1 - i] = map[i][j];
				}
			}

			// 180도
			int[][] map_180 = new int[n][n];
			for (int i = 0; i < n; i++) {
				for (int j = n - 1; j >= 0; j--) {
					map_180[n - 1 - i][j] = map[i][n - 1 - j];
				}
			}

			// 270도
			int[][] map_270 = new int[n][n];
			for (int i = 0; i < n; i++) {
				for (int j = n - 1; j >= 0; j--) {
					map_270[j][i] = map[i][n - 1 - j];
				}
			}

			System.out.printf("#%d\n", t + 1);
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					System.out.print(map_90[i][j]);
				}
				System.out.print(" ");
				for (int j = 0; j < n; j++) {
					System.out.print(map_180[i][j]);
				}
				System.out.print(" ");
				for (int j = 0; j < n; j++) {
					System.out.print(map_270[i][j]);
				}
				System.out.println();
			}
		}
		sc.close();
	}
}

자리 위치만 확인하면 되는 문제

 

 

 

 

 

 

 

 

 

# SWEA 숫자 배열 회전


 

728x90