arr = [4, 1, 6, 3]
count = 0

n = len(arr)
for i in range(n - 1):
    minindex = i
    for j in range(i + 1, n):
        if arr[j] < arr[minindex]:
            minindex = j
    if minindex != i:
        arr[i], arr[minindex] = arr[minindex], arr[i]
        count += 1

print("스왑 횟수:", count)

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: