1 void insert_sort() 2 { 3 int i,j; 4 unsigned char array[10] = {4,1,3,9,6,2,8,5,0,7}; 5 unsigned char len = sizeof(array); 6 7 /*遍历所有无序序列*/ 8 for(i = 1; i< len; i++) 9 { 10 unsigned char temp = array[i]; 11 /*遍历所以有序序列,排序*/ 12 for(j=i-1; j>=0 && temp < array[j]; j--) 13 { 14 array[j+1] = array[j]; 15 } 16 array[j+1] = temp; 17 } 18 for(i=0;i<10;i++) 19 { 20 printf("%d\n",array[i]); 21 } 22 }
标签:10,temp,插入排序,unsigned,char,array,直接 From: https://www.cnblogs.com/njit-sam/p/17645798.html