快速排序算法-容器存储vector

<pre name="code" class="cpp">int quicksort(vector<int> &v, int left, int right){ if(left < right){ 
	int key = v[left]; int low = left; int high = right; 
	while(low < high){ 
			while(low < high && v[high] > key){
                                high--;
                        }
                        v[low] = v[high]; 
			while(low < high && v[low] < key){
                                low++;
                        }
                        v[high] = v[low];
                }
                v[low] = key;
                quicksort(v,left,low-1);
                quicksort(v,low+1,right);
        }
}





                                    
posted @ 2015-10-17 12:45  cloudren2020  阅读(126)  评论(0编辑  收藏  举报