for j = 2 to A.length
key = a[j]
i = j - 1
while i > 0 && a[i] > key
a[i + 1] = a[ i ]
i = i - 1
a[ i + 1] = key
for j = 2 to A.length
key = a[j]
i = j - 1
while i > 0 && a[i] > key
a[i + 1] = a[ i ]
i = i - 1
a[ i + 1] = key
转载于:https://www.cnblogs.com/AsentONE/p/4165786.html