void swap(int* a,int* b)
{
int temp;
temp=*a;
*a=*b;
*b=temp;
}
void selectSort(int* array, int nLen)
{
for (int i=0;i!=nLen;i++)
{
int temp=i;
for (int j=i+1;j!=nLen;j++)
{
if (array[j]<array[temp])
{
temp=j;
}
}
swap(array[i],array[temp]);
}
}
选择排序
最新推荐文章于 2022-08-23 16:09:03 发布