选择排序
#include <stdio.h>
void xuanze(int a[],int n){
int max;
for(int i = 0; i < n; i++){
max = i;
for(int j = max + 1; j <= n; j++){
if(a[max] > a[j]){
max = j;
}
}
if(i != max){
int temp = a[i];
a[i] = a[max];
a[max] = temp;
}
}
return;
}
int main(int argc, const char *argv[])
{
int a[]={1,2,5,7,34,67,3,8,324,97,65};
int con = sizeof(a)/sizeof(a[0])-1;
xuanze(a,con);
for(int i = 0; i <= con; i++)
printf("%d ",a[i]);
return 0;
}