#include<stdio.h>
void printarry(int a[], int length);
void insertSort(int arry[], int length);
void printarry(int a[], int length,int n) {
if (n)
printf("排好序的数:");
else
printf("未排好序的数:");
for (int i = 1; i < length; i++)
{
printf("-%d", a[i]);
}
printf("\n");
}
void insertSort(int arry[], int length) {
int i;
i = 2;
for (i; i <= length - 1; i++) {
arry[0] = arry[i];
int j = i - 1;
while (arry[0] < arry[j])
{
arry[j + 1] = arry[j];
j--;
}
arry[j + 1] = arry[0];
}
}
int main(void) {
int arry[] = { 0,15,56,25,35,85,63,21,56,15,25,80,90,50,12,53,12,50 };
int length = sizeof(arry) / sizeof(int);
int flag;
flag = 0;
printarry(arry,length,flag);
insertSort(arry,length);
flag = 1;
printarry(arry,length,flag);
}