INSERT SORT
2017-11-27 本文已影响0人
larrymusk
void insert(int A[], int len)
{
int j;
for(int i = 1; i < len; i++){
if(A[i] < A[i-1]){
int tmp = A[i];
//from [0, i-1] let all A[x] (x<=i-1) move left
for(j = i-1; j >=0 && A[j] >= tmp; j--)
A[j+1] = A[j];
//here A[j] < A[i]
A[j+1] = tmp;
}
}
}
int m