1 void select_sort() 2 { 3 int i,j,k; 4 unsigned char array[10] = {4,1,3,9,6,2,8,5,0,7}; 5 unsigned char len = sizeof(array); 6 unsigned char temp; 7 8 for(i = 0; i< len-1; i++) 9 { 10 k = i; 11 /*遍历所以有序序列,排序*/ 12 for(j=i+1; j < len; j++) 13 { 14 if(array[j] < array[k]) 15 { 16 k = j; 17 } 18 } 19 temp = array[i]; 20 array[i] = array[k]; 21 array[k] = temp; 22 } 23 for(i=0;i<10;i++) 24 { 25 printf("%d\n",array[i]); 26 } 27 }
标签:char,temp,unsigned,len,选择,简单,array,排序 From: https://www.cnblogs.com/njit-sam/p/17645927.html