选择排序的总结

数据结构排序算法之——选择排序(Select Sort)

选择排序想关链接:

维基百科:https://zh.wikipedia.org/zh/%E9%80%89%E6%8B%A9%E6%8E%92%E5%BA%8F

百度百科:http://baike.baidu.com/view/547263.htm

选择排序的基本思想:

就是每次在无序的数组选择一个一个最小的(或者最大的)数,放在已经有序的后面

代码

void Select_Sort(int array[], int arrayLen)

{

 

    for (int i = 0; i < arrayLen; ++i)

    {

        int tempIndex = i;

        for (int j = i + 1; j < arrayLen; ++j)

        {

            // 由小到大

 

            if (array[j] < array[tempIndex])

            {

                tempIndex = j;

            }

        }

 

        if (i != tempIndex)

        {

            Swap_IntVal(array + i, array + tempIndex);

        }

    }

}

详细的代码:代码地址应该会选择放在github,但是最近我对github的操作还不是很熟悉

原文地址:https://www.cnblogs.com/bkcarlos/p/5860646.html