void InsertSort(int A[],int n){
int i,j;
for(i = 2;i<=n;i++)
{
if(A[i]<A[i-1])//A[i]小于其前驱,将A[i]插入有序表
{
A[0] = A[i];//哨兵
for(j = i-1;A[0]<A[j];j--)
A[j+1] = A[j];//向后挪位
A[j+1] = A[0];//复制到插入位置
}
}
}

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



