[演算法笔记] 选择排序

#include <stdio.h>

int slection_sort(int array[], int n)
{
    for (int i = 0; i < n; i++){
        int min_index = i;
        for (int j = i + 1; j < n; j++)
            if (array[j] < array[min_index]){
                min_index = j;
            }
        swap(array[i], array[min_index]);
    }
}

 

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注