插入排序:
[cpp]
void Insert_Sort(int *a, int size)
{
if(size <= 1)
return;
int key = 0;
int i = 0, j = 0;
for (i = 1; i < size - 1; i++)
{
key = a[i];
for (j = i - 1; j >= 0; j--)
{
if(a[j] > key)
a[j + 1] = a[j];
else
break; www.2cto.com
}
a[j + 1] = key;
}
}