标签:image div style static amp code log out images
1、使用直接插入排序法排序
1 public class InsertSort { 2 3 public static void main(String[] args) { 4 // TODO Auto-generated method stub 5 int[] array = new int[]{50,40,90,30,80}; 6 System.out.println("排序前:"); 7 for(int i=0;i<array.length;i++){ 8 System.out.print(array[i]+"\t"); 9 } 10 11 int tmp; 12 int k; 13 for(int i=1;i<array.length;i++){ 14 tmp = array[i]; 15 for(k=i-1;k>=0&&array[k]>tmp;k--){ 16 array[k+1]=array[k]; 17 } 18 array[k+1]=tmp; 19 } 20 System.out.println("\n排序后:"); 21 for(int i=0;i<array.length;i++){ 22 System.out.print(array[i]+"\t"); 23 } 24 } 25 26 }
标签:image div style static amp code log out images
原文地址:http://www.cnblogs.com/feimanzhh/p/6087564.html