From 251b6d6f5b28fb815ea275104ff1a1edc495031d Mon Sep 17 00:00:00 2001 From: heerucan Date: Wed, 16 Feb 2022 05:07:39 +0900 Subject: [PATCH] =?UTF-8?q?[=EC=BD=94=EB=94=A9=ED=85=8C=EC=8A=A4=ED=8A=B8?= =?UTF-8?q?=EC=B1=85]=206-1.=20=EC=9C=84=EC=97=90=EC=84=9C=20=EC=95=84?= =?UTF-8?q?=EB=9E=98=EB=A1=9C=20(#4)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...34\354\225\204\353\236\230\353\241\234.py" | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 "CodingTest/CH6 \354\240\225\353\240\254/\354\234\204\354\227\220\354\204\234\354\225\204\353\236\230\353\241\234.py" diff --git "a/CodingTest/CH6 \354\240\225\353\240\254/\354\234\204\354\227\220\354\204\234\354\225\204\353\236\230\353\241\234.py" "b/CodingTest/CH6 \354\240\225\353\240\254/\354\234\204\354\227\220\354\204\234\354\225\204\353\236\230\353\241\234.py" new file mode 100644 index 0000000..a03eb60 --- /dev/null +++ "b/CodingTest/CH6 \354\240\225\353\240\254/\354\234\204\354\227\220\354\204\234\354\225\204\353\236\230\353\241\234.py" @@ -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) \ No newline at end of file