#include<stdio.h>
void selectsort(int a[], int n)
{
for (int i = 0; i < n - 1; i ++)
{
//int min = i;
for (int j = i + 1; j < n; j++)
{
if (a[i] > a[j])
{
int temp=a[i];
a[i] = a[j];
a[j] = temp;
}
}
}
}
int main()
{
int a[] = { 11,4,66,22,78,22,1,78,99,23 };
selectsort(a, 10);
for (int i = 0; i < 10; i++)
printf("%d ", a[i]);
}
选择排序,没什么好说的凑字数
最新推荐文章于 2024-07-14 17:43:36 发布