天空是藍色的

          做好軟件為中國 #gcc -c helloworld.c -o helloworld.o //編譯目標文件 #gcc helloworld.o -o helloworld //編譯成可執行exe #helloworld //運行exe
          數據加載中……
          [轉載]快速排序
          快速排序 
           
          class Test {
           
           public static void quickSort( int
          [] intArr, int startIndex, int endIndex ) {
            int left 
          = startIndex;
            int right = endIndex;
            int pivot = (left+right)/2;
            int tmp = 0;
            
            do {
             while( intArr
          [left]<intArr[pivot] )  left++;
             while( intArr[right] > intArr[pivot] ) right--;
             
             if( left<
          =right ) {
              tmp 
          = intArr[left];
              intArr[left] = intArr[right];
              intArr[right] = tmp;
              left++;
              right--;
             }
            }while(left<
          =right);
            
            if( left<endIndex ) quickSort( intArr
          , left, endIndex );
            if( right>startIndex ) quickSort( intArr, startIndex, right);
           }
                
           public static void main( String
          [] argus ) {
            int
          [] test = new int[]{5,4,3,2,1};
            quickSort( test, 0 , test.length-1 );
            for ( int i=0; i<test.length; i++ )  System.out.print( "test["+i+"]="+test[i]+"    " );
           }

          http://spaces.msn.com/members/zhangqingqi/

          posted on 2005-12-31 10:30 bluesky 閱讀(497) 評論(0)  編輯  收藏 所屬分類: 記事本

          主站蜘蛛池模板: 都江堰市| 新建县| 即墨市| 合江县| 滕州市| 漳浦县| 东安县| 娄底市| 万年县| 陈巴尔虎旗| 沂源县| 和林格尔县| 延吉市| 彩票| 栾川县| 元朗区| 石狮市| 惠水县| 乌鲁木齐市| 北海市| 丹巴县| 荔波县| 文山县| 库尔勒市| 陆丰市| 峨眉山市| 比如县| 乐山市| 钦州市| 湖口县| 巴彦淖尔市| 临安市| 马龙县| 安阳市| 盘山县| 丹凤县| 长葛市| 金昌市| 东安县| 革吉县| 绥滨县|