Created
May 24, 2017 02:06
-
-
Save hongdonghyun/a1173fdd441a17d52ccd7a2cd1cf65b0 to your computer and use it in GitHub Desktop.
버블버블
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
random_list = [random.randint(1,100) for i in range(20)] | |
print('== 버블 정렬 전 리스트 ==\n {}'.format(random_list)) | |
def bubble_sort(input_list): | |
length =len(input_list) -1 | |
for index in range(length): | |
for index2 in range(length-index): | |
if input_list[index2] > input_list[index2+1]: | |
input_list[index2],input_list[index2+1]=input_list[index2+1],input_list[index2] | |
return input_list | |
print('== 버블 정렬 후 리스트 ==\n ') | |
print(bubble_sort(random_list)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment