选择排序

 1 void selectSort(int array[], int n) {
 2     int current;
 3     for (current = 0; current < n; ++current) {
 4         int i, min = array[current], minIndex = current; 
 5         for (i = current; i < n; ++i) {
 6             if (array[i] < min) {
 7                 min = array[i];
 8                 minIndex = i;
 9             }
10         }
11         swap(&array[current], &array[minIndex]);
12     }
13 }
选择排序

 

posted @ 2020-04-18 11:01  小茗从不写博客  阅读(98)  评论(0)    收藏  举报