隨筆 - 1, 文章 - 7, 評論 - 3, 引用 - 0
          數據加載中……

          CommonSort


          public class CommonSort {
              
              
          public CommonSort()
              
          {
                  
              }

              
              
          static int[] srcArray = new int[]{49,386597 ,76 ,13 ,2749}
              
          static int[] sortArray;
              
          static int[] getArray;
              
              
              
          public static int[] InsertSort(int[] sa)
              
          {
                  
          int length = sa.length;
                  sortArray 
          = null;
                  sortArray 
          = new int[length];
                  
          int j;
                  
          for(int i=0;i<length;i++)
                  
          {
                      printArray(sortArray);
                      sortArray[
          0]=sa[i];
                      j
          =i-1;
                      
          while(i>=2&&sortArray[0]<sortArray[j])
                      
          {
                          sortArray[j
          +1]=sortArray[j];
                          j
          --;
                      }

                      
          if(i<2)
                      
          {
                          sortArray[j
          +2]=sortArray[0];
                      }

                      
          else
                          sortArray[j
          +1]=sortArray[0];
                  }

                  
          return sortArray;
              }

              
              
          public static int[] SelectSort(int[] sa)
              
          {
                  
                  
          return sortArray;
              }

              
              
          public static int[] BubbleSort(int[] sa)
              
          {
                  
          return sortArray;
              }

              
              
          public static int[] QuickSort(int[] sa)
              
          {
                  
          return sortArray;
              }

              
              
          public static int[] HeapSort(int[] sa)
              
          {
                  
          return sortArray;
              }

              
              
          public static void printArray(int[] pa)
              
          {
                  
          int length = pa.length;
                  
          for(int i=0;i<length;i++)
                  
          {
                      System.out.println(
          "array["+i+"]"+pa[i]);
                  }

                  System.out.println(
          "length:"+length+":---------------.");
              }

              
              
          public static void main(String[] args)
              
          {
                  getArray
          =null;
                  printArray(srcArray);
                  getArray
          =InsertSort(srcArray);
                  printArray(getArray);
              }

              


          }

          posted on 2007-08-28 07:44 Java ME---------F6ME 閱讀(113) 評論(0)  編輯  收藏


          只有注冊用戶登錄后才能發(fā)表評論。


          網站導航:
          博客園   IT新聞   Chat2DB   C++博客   博問  
           
          主站蜘蛛池模板: 怀宁县| 合江县| 齐齐哈尔市| 建水县| 巴青县| 平潭县| 宝兴县| 景洪市| 房产| 雅安市| 龙川县| 陵水| 阳原县| 甘孜| 祁连县| 荣昌县| 蒲江县| 会泽县| 元谋县| 邹平县| 武强县| 苗栗县| 宜昌市| 拜泉县| 兴文县| 康平县| 清涧县| 桑植县| 嘉荫县| 南漳县| 松桃| 康平县| 海安县| 湘阴县| 屏山县| 甘南县| 永定县| 罗源县| 鄢陵县| 广昌县| 龙泉市|