//选择排序 void SekectSort(int a[], int len) { for (int i = 0; i < len; i++) { int min = a[i]; int loc = i; //寻找最小的元素 for (int j = i + 1; j < len; j++) { if (a[j] < min) { min = a[j]; loc = j; } } //把最小的元素放在有序区后面 int temp = a[loc]; a[loc] = a[i]; a[i] = temp; } }