常见排序之简单选择排序


#include <stdio.h>

void Simple_Select_Sort(int *Array,int length)
{
int i,j,min,temp;

for(i = 0; i < length; i++)
{
min = i;

for(j = i+1; j < length; j++)
{
if(Array[min] > Array[j])
{
min = j;
}
}

if(min != i)
{
temp = Array[min];
Array[min] = Array[i];
Array[i] = temp;
}
}

for(i = 0; i <length; i++)
{
printf("%d\n",Array[i]);
}
}

int main(void)
{
int cnt ;

int Array_Test[] = {2,4,5,1,3,8,6,7,9,0};

Simple_Select_Sort(Array_Test,10);

return 0;

}

猜你喜欢

转载自www.cnblogs.com/muzixiaofeng/p/10088611.html