#include <stdio.h> void sort( int * const arraynumber,int len,int *head); int main(void){ int j; int arraynumber[]={3,5,1,4,2,9,4,6,3,8,7,0,-1,-3}; int len=sizeof(arraynumber)/sizeof(int); int sortarray[len]; sort(arraynumber,len,sortarray); for(j=0;j<len;j++) printf("%d\n",sortarray[j]); return 0; } void sort(int *const arraynumber,int len,int *head){ int i,j,k,*p,hlen; p=head; *p=arraynumber[0]; hlen=1; for(j=1;j<len;j++){ i=0; while(i<hlen&&*(p+i)<arraynumber[j]&&++i); for(k=hlen;k>i;k--) *(p+k)=*(p+k-1); *(p+i)=arraynumber[j]; hlen++; } }
每周一练,day day up!