public class Solution {
void insertSort(int[] a) {
int j;
for (int p = 1; p < a.length; ++p) {
int tmp = a[p];
for (j = p; j > 0 && tmp < a[j-1]; --j) {
a[j] = a[j - 1];
}
a[j] = tmp;
}
}
}
public class Solution {
void insertSort(int[] a) {
int j;
for (int p = 1; p < a.length; ++p) {
int tmp = a[p];
for (j = p; j > 0 && tmp < a[j-1]; --j) {
a[j] = a[j - 1];
}
a[j] = tmp;
}
}
}
本文标题:排序算法4——插入排序
本文链接:https://www.haomeiwen.com/subject/cdwugltx.html
网友评论