#include <stdio.h>
void Direct_Insert_Sort(int *Array)
{
int i,j,temp;
for(i = 1; i < 5; i++)
{
if(Array[i]<Array[i-1])
{
temp = Array[i];
for(j = i-1; j>=0 && Array[j] > temp; j--)
{
Array[j+1] = Array[j];
}
Array[j+1] = temp;//此处因为j = -1
}
}
}
int main(void)
{
int i;
int Array_Sort[] = {3,2,4,5,8};
Direct_Insert_Sort(Array_Sort);
for(i = 0; i < 5; i++)
{
printf("%d\r\n",Array_Sort[i]);
}
return 0;
}