#include <stdio.h>
#define N 20
void fun (int a[], int n)
{
int i, j , t, p;
for( j=0; j<n-1; j++)
{
p=j;
for ( i=j+1; i<n; i++)
{
if(a[i]<a[p])
p=i;
}
if (p! = j)
{
t=a[p];
a[p]=a[j];
a[j]=t;
}
}
}
main()
{ int a[N]={9,6,8,3,-1}, i, m=5;
printf (“排序前的数据:”);
for (i=0; i<m; i++) printf (“%d”, a[i]);
printf (“\n”);
fun(a, m);
printf(“排序后的数据:”);
for(i=0; i<m; i++) printf (“%d”,a[i]);
printf (“\n”);
}
05-23
4473
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
07-02
1万+
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
05-17
757
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
05-25