美文网首页
Insertion Sort

Insertion Sort

作者: 綿綿_ | 来源:发表于2019-03-31 18:37 被阅读0次
public class InsertionSort {
    static final int SIZE=10;
    public static void insertionSort(int[] a)
    {
        int i,j,t,h;
        for (i=1;i<a.length;i++)
        {
            t=a[i];
            j=i-1;
            while(j>=0&&t<a[j])
            {
                a[j+1]=a[j];
                j--;
            }
            a[j+1]=t;
        }
    }
}

相关文章

网友评论

      本文标题:Insertion Sort

      本文链接:https://www.haomeiwen.com/subject/jpeubqtx.html