(3)用 java 实现
0
1
packagecom.njue
;
0
2
0
3
publicclassinsertSort {
0
4
publicinsertSort(){
0
5
inta[]={49,38,65,97,76,13,27,49,78,34,12,64,5,4,62,99,98,54,5
6,17,18,23,34,15,35,25,53,51};
0
6
inttemp=0;
0
7
for(inti=1;i<a.length;i++){
0
8
intj=i-1;
0
9
temp=a[i];
1
0
for(;j>=0&&temp<a[j];j--){
1
1
a[j+1]=a[j];//将大于 temp 的值整体后移一个单位
1
2
}
1
3
a[j+1]=temp;
1
4
}
1 for(inti=0;i<a.length;i++)