📄 insertsort.java
字号:
public class InsertSort{
public static void insertSort(int[] a){
int i, j, temp;
int n = a.length;
for(i = 0; i < n - 1; i ++){
temp = a[i + 1];
j = i;
while(j > -1 && temp <= a[j]){
a[j + 1] = a[j];
j --;
}
a[j + 1] = temp;
}
}
public static void main(String[] args){
int[] test = {64, 5, 7, 89, 6, 24};
int n = test.length;
insertSort(test);
for(int i = 0; i < n; i ++)
System.out.print(test[i] + " ");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -