标签:快速排序
先手打一个快速排序热身
排序方法很多,选一个快速排序傍身没错的
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);
}
版权声明:本文为博主原创文章,未经博主允许不得转载。
标签:快速排序
原文地址:http://blog.csdn.net/serapme/article/details/46992477