Algorithm/Simulation

[백준] 2947번 나무조각

등촌동 꼬북이 2020. 11. 27. 01:38

쉬운 문제..

 

def printList(L):
    for i in range(len(L)):
        print(L[i], end=" ")
    print()

inputList = list(map(int, input().split()))
sortedList = sorted(inputList)

while inputList != sortedList:
    for i in range(len(inputList) - 1):
        if inputList[i] > inputList[i + 1]:
            temp = inputList[i + 1]
            inputList[i + 1] = inputList[i]
            inputList[i] = temp
            printList(inputList)