728x90
https://www.acmicpc.net/problem/2947
2947번: 나무 조각
첫째 줄에 조각에 쓰여 있는 수가 순서대로 주어진다. 숫자는 1보다 크거나 같고, 5보다 작거나 같으며, 중복되지 않는다. 처음 순서는 1, 2, 3, 4, 5가 아니다.
www.acmicpc.net
inp = list(map(int, input().split()))
while 1:
if inp == [1, 2, 3, 4, 5]:
break
if inp[0] > inp[1]:
tmp = inp[0]
inp[0] = inp[1]
inp[1] = tmp
for i in inp:
print(i, end = ' ')
print()
if inp[1] > inp[2]:
tmp = inp[1]
inp[1] = inp[2]
inp[2] = tmp
for i in inp:
print(i, end = ' ')
print()
if inp[2] > inp[3]:
tmp = inp[2]
inp[2] = inp[3]
inp[3] = tmp
for i in inp:
print(i, end = ' ')
print()
if inp[3] > inp[4]:
tmp = inp[3]
inp[3] = inp[4]
inp[4] = tmp
for i in inp:
print(i, end = ' ')
print()
반응형
'전.py' 카테고리의 다른 글
백준 2846 오르막길 (0) | 2020.12.11 |
---|---|
백준 2857 FBI (0) | 2020.12.11 |
백준 2966 찍기 (0) | 2020.12.11 |
백준 3004 체스판 조각 (0) | 2020.12.11 |
백준 3035 스캐너 (0) | 2020.12.11 |