选择排序

 1 void Swap(ElementType *a, ElementType *b)
 2 {
 3     ElementType tmp = *a;
 4     *a = *b;
 5     *b = tmp;
 6 }
 7 
 8 //选择排序
 9 void SelectionSort(ElementType A[], int N)
10 {
11     for(int i = 0; i < N-1; ++i)
12     {
13         int MinPos = i;
14         for(int j = i+1; j < N; ++j)
15         {
16             if(A[j] < A[MinPos])
17                 MinPos = j;             //记录最小值的位置下标
18         }
19         Swap(&A[i], &A[MinPos]);
20     }
21 }
原文地址:https://www.cnblogs.com/FengZeng666/p/9516422.html