![](https://video.ask-data.xyz/img.php?b=https://iknow-pic.cdn.bcebos.com/024f78f0f736afc3b8ae2729b919ebc4b64512df?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto)
#include<stdio.h>
void Sort(int *a,int n) {
int *p,*q,*v,t;
for(p = a;p < a + n - 1;++p) {
v = p;
for(q = p + 1; q < a + n; ++q)
if(*v > *q) v = q;
if(*p != *v) {
t = *p;
*p = *v;
*v = t;
}
}
}
void Show(int *a,int n) {
int i;
for(i = 0; i < n; ++i)
printf("%d ",*(a + i));
printf("\n");
}
int main() {
int a[] = {23,12,54,89,66,59,57,48,91,20,31};
int n = sizeof(a)/sizeof(a[0]);
printf("排序前:\n");
Show(a,n);
printf("排序后:\n");
Sort(a,n);
Show(a,n);
return 0;
}