#include <stdio.h>
#define SIZE 8
void SelectSort(int R[], int n);
void SelectSort(int R[], int n)
{
int i, j, m;
int t;
for(i=0; i<n-1; i++)//
{
m = i;
for(j = i+1; j < n; j++)
{
if(R[j] < R[m])
m = j;
}
if(m != i)
{
t = R[i];
R[i] = R[m];
R[m] = t;
}
}
}
int main()
{
int number[SIZE]={95,45,15,78,84,51,24,12};
int i;
SelectSort(number,SIZE);
for(i=0;i<SIZE;i++)
{
printf("%d\n",number[i]);
}
printf("\n");
}
直接排序(固定长度数组)
最新推荐文章于 2024-04-28 14:42:54 发布