- //选择排序代码实现
- #include <stdio.h>
- int main(){
- int a[] = {1,5,12,8,36,25,98,63,88,76};
- int i,j,temp;
- int len = sizeof(a)/sizeof(int);
- printf("%d\n",len);
- for(i=0;i<len-1;i++){
- for(j=i+1;j<len;j++){
- if(a[i]>a[j]){
- temp = a[i];
- a[i] = a[j];
- a[j] =temp;
- }
- }
- }
- for(i=0;i<len;i++){
- printf("%d\t",a[i]);
- }
- return 0;
- }
复制代码
|
|