快速排序

先手打一个快速排序热身
排序方法很多,选一个快速排序傍身没错的
code:

public void QuickSort(int[] data,int start ,int end) { int low = start; int high = end; if(low < high) { int tmp = data[low]; while(low<high) { while(low<high && tmp<data[high]) high--; if(low < high){ data[low] = data[high]; low++; }
            while(low<high && tmp >data[low])
                low++;
            if(low < high){
                data[high] = data[low];
                high--;
            }
        }
        data[low] = tmp;
        QuickSort(data, start, low-1);
        QuickSort(data, low+1, end);
}   

你可能感兴趣的:(快速排序)