#include<iostream>
using namespace std;
#define N 10
void Select_Sort(int* arr, int n) //arr为数据数组,n为数组长度
{
for (int i = 0; i < n-1; i++) {
int min = i;
for (int j = i+1; j < n; j++) {
if (arr[min] > arr[j]) {
min = j;
}
}
if (min != i) {
swap(arr[i], arr[min]);
}
}
}
int main()
{
int arr[N]= { 1,4,6,3,0,2,5,9,8,7 };
Select_Sort(arr, 10);
for (int i = 0; i < N; i++)
{
cout << arr[i] << ",";
}
cout << endl;
return 0;
}
09-06
138
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)