Insertion Sort

2019-03-31  本文已影响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;
        }
    }
}
上一篇 下一篇

猜你喜欢

热点阅读