标签:tput blog std clu span 排序 pre main output
#include <stdio.h> void select(int a[],int n){ int i,j,k,x; int z; for(i=0;i<n-1;i++){ k=i; for(j=i+1;j<n;j++) if(a[j]<a[k]) k=j; if (k!=i){ x=a[i]; a[i]=a[k]; a[k]=x; } for(z=0;z<n;z++) printf("%d\t",a[z]); printf("\n"); } } int main(){ int i; int a[]={45,38,66,90,88,10,25,45}; select(a,8); /*for(i=0;i<13;i++) printf("%d\t",a[i]);*/ return 0; }
输出结果:
Output: 10 38 66 90 88 45 25 45 10 25 66 90 88 45 38 45 10 25 38 90 88 45 66 45 10 25 38 45 88 90 66 45 10 25 38 45 45 90 66 88 10 25 38 45 45 66 90 88 10 25 38 45 45 66 88 90
标签:tput blog std clu span 排序 pre main output
原文地址:http://www.cnblogs.com/OneL1fe/p/6561106.html