/* insertion-sort */
int insertion_sort(int* arr, unsigned int arrCount)
{
unsigned int iLoop = 0;
unsigned int jLoop = 0;
int numInsert = 0;
if(arr == NULL)
{
return -1;
}
for(iLoop = 1; iLoop < arrCount; ++iLoop)
{
numInsert = arr[iLoop];
for(jLoop = iLoop - 1; jLoop >= 0; --jLoop)
{
if(arr[jLoop] > numInsert)
{
arr[jLoop + 1] = arr[jLoop];
if(jLoop == 0)
{
arr[jLoop] = numInsert;
break;
}
}
else
{
arr[jLoop + 1] = numInsert;
break;
}
}
}
return 0;
}
这么早就睁不开眼了,先写着一个,罪过罪过
2950

被折叠的 条评论
为什么被折叠?



