标签:选择排序 for code sel color stdio.h turn logs std
#include<stdio.h> void SelectSort(int a[],int n){ int i,j,min,temp; for( i=0;i<n-1;i++ ){ min = i; for(j=i+1;j<n;j++) { if ( a[j] < a[min]){ min = j; } } if(min != i){ temp = a[min]; a[min] = a[i]; a[i] = temp; } } } int main() { int i; int a[10] = {34,54,2,65,2,67,4543,123,64,6}; printf("排序后:"); SelectSort(a,10); for(i=0;i<10;i++) { printf("%d ",a[i]); } printf("\n"); return 0; }
标签:选择排序 for code sel color stdio.h turn logs std
原文地址:http://www.cnblogs.com/ncuhwxiong/p/7436967.html