InsertionSort

void InsertionSort(int *array, int length)
{
	int i,j;
	int temp;
	for (i = 1; i < length; i++)
	{
		temp = array[i];
		for(j = i - 1; j >= 0 && temp < array[j]; j--)
		{
			array[j+1] = array[j];					//移位
		}
		array[j+1] = temp;
	}
}
直接插入排序

猜你喜欢

转载自blog.csdn.net/qq_38960899/article/details/78704223