标签:for std include col print printf style clu bsp
//选择排序(升序) #include<stdio.h> #include<time.h> void fun(int a[],int n) { int i,j,k,t; 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) { t=a[i]; a[i]=a[k]; a[k]=t; } } } main() { int a[10],i; srand(time(0)); for(i=0;i<10;i++) a[i]=rand()%100; printf("原数组:\n"); for(i=0;i<10;i++) printf("%4d",a[i]); fun(a,10); printf("\n排序后数组:\n"); for(i=0;i<10;i++) printf("%4d",a[i]); }
标签:for std include col print printf style clu bsp
原文地址:https://www.cnblogs.com/yanglike111/p/13171299.html