Partition函数
来源:互联网 发布:中国的阿拉伯之春 知乎 编辑:程序博客网 时间:2024/05/22 10:34
#include<iostream>using namespace std;int Partition(int arr[],int low,int high){ int nSmall = low-1; for(;low<high;low++) { if(arr[low] < arr[high]) { nSmall++; if(low != nSmall) { arr[low] = arr[low] ^ arr[nSmall]; arr[nSmall] =arr[low] ^arr[nSmall]; arr[low] =arr[low] ^ arr[nSmall]; } } } nSmall++; if(nSmall != high) { arr[high] = arr[high] ^ arr[nSmall]; arr[nSmall] =arr[high] ^arr[nSmall]; arr[high] =arr[high] ^ arr[nSmall]; } return nSmall;}void QuickSort(int arr[],int low,int high){ if(low < high) { int mid = Partition(arr,low,high); QuickSort(arr,low,mid-1); QuickSort(arr,mid+1,high); }}int main(){ int arr[]={0,3,8,3,8,3,9,2,8,2}; for(int i = 0 ; i < 10 ;i++) { cout<<arr[i]<<" "; } cout<<endl; QuickSort(arr,0,9); for(int i = 0 ; i < 10 ;i++) { cout<<arr[i]<<" "; } cout<<endl; return 0;}
1 0
- partition函数
- Partition函数
- partition函数
- Partition函数
- 分析函数partition by
- partition函数的实现
- 快排中partition函数-java
- over partition by 函数
- 基本算法-partition函数
- Python的partition字符串函数
- oracle rank,over partition 函数
- OVER(PARTITION BY)函数介绍
- OVER(PARTITION BY)函数介绍
- Python的partition字符串函数
- OVER(PARTITION BY)函数介绍
- OVER(PARTITION BY)函数介绍
- OVER(PARTITION BY)函数介绍
- OVER(PARTITION BY)函数介绍
- LeetCode 36: Valid Sudoku
- zoj3905 Cake (简单dp)
- 2015-2016 ACM-ICPC, NEERC, Moscow Subregional Contest H题: Hashing [基础DP]
- HDU-1551 Cable master
- kafka及zookeeper安装部署
- Partition函数
- window7下用wubi安装ubuntu
- IDF 牛刀小试-ASCII码而已
- iOS开发9-iOS操作SQLite数据库增删改查
- Swift2.0推送
- C# 多线程学习系列一:认识多线程
- 内部类一
- 求100以内的素数2015 10 24
- 杭电1163--9余项定理的例子