void
insertion_sort(
int
array[],
int
first,
int
last)
{
int
i,j;
int
temp;
for
(i = first+1; i<=last;i++)
{
temp = array[i];
j=i-1;
//与已排序的数逐一比较,大于temp时,该数移后
while
((j>=first) && (array[j] > temp)){
array[j+1] = array[j];
j--;
}
array[j+1] = temp;
}
}
原文:http://www.cnblogs.com/yulang314/p/3558538.html