Skip to content

Commit

Permalink
[코딩테스트책] 6-1. 위에서 아래로 (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
heerucan committed Feb 15, 2022
1 parent 0b261fa commit 251b6d6
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions CodingTest/CH6 정렬/위에서아래로.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
N = int(input())
array = []
for i in range(N):
array.append(int(input()))

# 선택정렬
def selectionSorting(list):
for i in range(len(list)):
max = i
for j in range(i+1, len(array)):
if list[max] < list[j]:
max = j
list[i], list[max] = list[max], list[i]
print(list)

selectionSorting(array)


# 삽입정렬
def insertSorting(list):
for i in range(1, len(list)):
j = i
while j > 0 and list[j-1] < list[j]:
list[j-1], list[j] = list[j], list[j-1]
j -= 1
print(list)

insertSorting(array)


# 정렬 라이브러리 사용
array.sort(reverse=True)
print(array)

0 comments on commit 251b6d6

Please sign in to comment.