#include <iostream>
using namespace std;
void SelectSort(int* a, int n)
{
for(int i=0; i<n-1; i++)
{
int minIndex=i;
for(int j =i+1; j<n; j++)
{
if(a[j] < a[minIndex])
{
minIndex = j;
}
}
if(minIndex != i)
{
int temp = a[i];
a[i] = a[minIndex];
a[minIndex] = temp;
}
}
}
int main()
{
int arr[] = {56, 60, 70, 90, 80, 10, 20, 40};
int len = sizeof(arr)/sizeof(arr[0]);
SelectSort(arr, len);
for(int i =0; i<len; i++)
{
printf("%d ", arr[i]);
}
return 0;
}
11-08
140
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
07-23
678
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
07-23
571
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)