C语言选择排序算法示例:

include

int main() {

int n;

scanf("%d",&n);

int i,j,xuanze,t;

int a[256];

for(i=0;i

scanf("%d",&a[i]);

for(i=0;i

xuanze=i;

for(j=i+1;j

if(a[j]

xuanze=j;

}

}

t=a[xuanze];

a[xuanze]=a[i];

a[i]=t;

}

for(i=0;i

printf("%d",a[i]);

if(i!=n-1)

printf(" ");

}

return 0;

}