1

これが私のコードです

count = 0
def selectionSort(data):


    for index in range(len(data)):

        min = index
        count += 1
        # Find the index'th smallest element
        for scan in range(index + 1, len(data)):

            if (data[scan] < data[min]):

                min = scan

        if min != index: # swap the elements
            data[index], data[min] = data[min], data[index]

    return data

data = selectionSort([3,4,5,2,6])


print(count, data)
4

1 に答える 1