SW Expert Academy

[SWEA] 숫자 배열 회전 (1961) Python

RiLLa_0511 2023. 5. 9. 20:54
728x90

https://swexpertacademy.com/main/code/problem/problemDetail.do?problemLevel=2&contestProbId=AV5Pq-OKAVYDFAUq&categoryId=AV5Pq-OKAVYDFAUq&categoryType=CODE&problemTitle=&orderBy=INQUERY_COUNT&selectCodeLang=PYTHON&select-1=2&pageSize=10&pageIndex=2 

 

 

SW Expert Academy

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

swexpertacademy.com

 

 

t = int(input())

for i in range(1, t + 1):
    n = int(input())
    lst = []
    for j in range(n):
        a = list(map(int, input().split()))
        lst.append(a)
        
    lst_90 = []
    lst_180 = []
    lst_270 = []
    
    for k in range(n):
        b = []
        for l in range(n):
            b.append(lst[n-l-1][k])
        lst_90.append(b)
        
    for q in range(n):
        c = []
        for p in range(n):
            c.append(lst_90[n-p-1][q])
        lst_180.append(c)
        
    for z in range(n):
        d = []
        for x in range(n):
            d.append(lst_180[n-x-1][z])
        lst_270.append(d)
        
    print("#{}".format(i))
    for y in range(n):
        for bb in range(n):
            print(lst_90[y][bb], end = '')
        print(end = ' ')
        for cc in range(n):
            print(lst_180[y][cc], end = '')
        print(end = ' ')
        for dd in range(n):
            print(lst_270[y][dd], end = '')
        print(end = ' ')
        print()

 

 

 

 

혼자 공부하며 올리는 블로그입니다. 틀린 내용은 댓글 남겨주시면 감사하겠습니다.