//插入排序算法 package sortproject; public class DirectSort { static void sort(int []a,int low,int high){ int temp;// int i,j; for(i=low+1;i<high;i++) { temp=a[i]; for(j=i-1;j>=0;j--) { if(a[j]>temp) a[j+1]=a[j]; else break; } a[j+1]=temp; } // for( i=0;i<5;i++) // System.out.println(a[i]); } public static void main(String[] args){ int []a={5,4,3,2,1}; sort(a,0,5); for(int i=0;i<5;i++) System.out.println(a[i]); } } *算法思想:向一段已排好的系列插入要的数字,在这个系列中找到这个数字的位置,在这之前应该让其他数字后退,排好一遍后,插入这个数字(此算法只共本人参考,因为写的不好了)