//展示数组(声明)voidshow(intnum[], intlength); intmain(void) { //初始化intnum[5] = {1, 8, 7, 5, 2}, i=0, j=0; printf("Your array is:\n"); show(num, 5); //遍历数组for (i=1; i<5; i++) { intk=num[i]; j=i-1; //依次往后移,直至找到第一个满足小于K的值while (j>=0&&num[j] >k) { num[j+1] =num[j]; j--; } //将K查到该值前面num[j+1] =k; } printf("After sort,your array is:\n"); show(num, 5); return0; } //展示数组(定义)voidshow(intnum[], intlength) { for (inti=0; i<length; i++) { printf("%3d", num[i]); } printf("\n"); }