参考}
#include<stdio.h>
#include<stdlib.h>
#define DATA_SIZE 10
void selection_sort(int array[],int num_size)
{
int index = 0,i = 0,j = 0,temp = 0;
for(i = 0;i < num_size-1;i++)
{
index = i;
for(j = i+1;j < num_size ;j++)
{
if(array[index] > array[j])
{
index = j;
}
}
if(index != i)
{
temp = array[i];
array[i] = array[index];
array[index] = temp;
}
}
}
int main(void)
{
int data[DATA_SIZE],i =0;
printf("the original data seq : ");
for(i = 0;i < DATA_SIZE;i++)
{
data[i] = rand() % 100;
printf("%d,",data[i]);
}
printf(" ");
selection_sort(data,DATA_SIZE);
printf("after selection sort the seq : ");
for(i = 0;i < DATA_SIZE;i++)
printf("%d,",data[i]);
printf(" ");
return 0;
}