Skip to content

Instantly share code, notes, and snippets.

@dongwooklee96
Created July 28, 2021 15:35
Show Gist options
  • Select an option

  • Save dongwooklee96/490ad57f7e803ca8b9c251953f0e4764 to your computer and use it in GitHub Desktop.

Select an option

Save dongwooklee96/490ad57f7e803ca8b9c251953f0e4764 to your computer and use it in GitHub Desktop.
8.1
"""
문제 : 버블 정렬을 구현하시오.
"""
from typing import List
def bubble_sort(arr: List[int]):
n = len(arr)
for i in range(n):
done_sort = True
for j in range(n - i - 1):
if arr[j] > arr[j + 1]:
arr[j], arr[j + 1] = arr[j + 1], arr[j]
done_sort = False
if done_sort:
break
return arr
if __name__ == "__main__":
lists = list(map(int, input().split()))
print(bubble_sort(lists))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment