Studio KimHippo :D

[Python / Algorithm Challenge] 6. 선택 정렬(미완) 본문

Python Study/Algorithm Challenge

[Python / Algorithm Challenge] 6. 선택 정렬(미완)

김작은하마 2019. 7. 8. 00:35

 

# -*- coding: utf-8 -*-
# NOTE : 삽입 정렬

def insertion_sort():
    arr = list(map(int, input('자료를 입력해 주세요. : ').split(' ')))

    for o_rep in range(1, len(arr)):

        for i_rep in range(o_rep):
            if arr[o_rep] == arr[i_rep]:
                pass

            else:
                if arr[o_rep] < arr[i_rep]:
                    arr[o_rep], arr[i_rep] = arr[i_rep], arr[o_rep]

                    print(arr)


    return arr

print(insertion_sort())
Comments