[backcolor=rgb(27, 36, 38) !important][size=1em]1
[backcolor=rgb(27, 36, 38) !important][size=1em]2
[backcolor=rgb(27, 36, 38) !important][size=1em]3
[backcolor=rgb(27, 36, 38) !important][size=1em]4
[backcolor=rgb(27, 36, 38) !important][size=1em]5
[backcolor=rgb(27, 36, 38) !important][size=1em]6
[backcolor=rgb(27, 36, 38) !important][size=1em]7
[backcolor=rgb(27, 36, 38) !important][size=1em]8
[backcolor=rgb(27, 36, 38) !important][size=1em]9
[backcolor=rgb(27, 36, 38) !important][size=1em]10
[backcolor=rgb(27, 36, 38) !important][size=1em]11
[backcolor=rgb(27, 36, 38) !important][size=1em]12
[backcolor=rgb(27, 36, 38) !important][size=1em]13
[backcolor=rgb(27, 36, 38) !important][size=1em]14
[backcolor=rgb(27, 36, 38) !important][size=1em]15
[backcolor=rgb(27, 36, 38) !important][size=1em]16
[backcolor=rgb(27, 36, 38) !important][size=1em]17
[backcolor=rgb(27, 36, 38) !important][size=1em]18
| [size=1em][backcolor=rgb(27, 36, 38) !important][size=1em]package com.njue;
[backcolor=rgb(27, 36, 38) !important][size=1em]
[backcolor=rgb(27, 36, 38) !important][size=1em]public class insertSort {
[backcolor=rgb(27, 36, 38) !important][size=1em]public insertSort(){
[backcolor=rgb(27, 36, 38) !important][size=1em] inta[]={49,38,65,97,76,13,27,49,78,34,12,64,5,4,62,99,98,54,56,17,18,23,34,15,35,25,53,51};
[backcolor=rgb(27, 36, 38) !important][size=1em] int temp=0;
[backcolor=rgb(27, 36, 38) !important][size=1em] for(int i=1;i<a.length;i++){
[backcolor=rgb(27, 36, 38) !important][size=1em] int j=i-1;
[backcolor=rgb(27, 36, 38) !important][size=1em] temp=a;
[backcolor=rgb(27, 36, 38) !important][size=1em] for(;j>=0&&temp<a[j];j--){
[backcolor=rgb(27, 36, 38) !important][size=1em] a[j+1]=a[j]; //将大于temp的值整体后移一个单位
[backcolor=rgb(27, 36, 38) !important][size=1em] }
[backcolor=rgb(27, 36, 38) !important][size=1em] a[j+1]=temp;
[backcolor=rgb(27, 36, 38) !important][size=1em] }
[backcolor=rgb(27, 36, 38) !important][size=1em] for(int i=0;i<a.length;i++)
[backcolor=rgb(27, 36, 38) !important][size=1em] System.out.println(a);
[backcolor=rgb(27, 36, 38) !important][size=1em]}
[backcolor=rgb(27, 36, 38) !important][size=1em]}
|