快速排序
来源:互联网 发布:网络优化前台累吗 编辑:程序博客网 时间:2024/05/22 14:58
#include< iostream>
using namespace std;
void quick_sort(int* num,int left,int right)
{
if(left < right){ int low=left; int high=right; int key=num[low]; while(low< high) { while(low< high&&num[high]>=key) --high; num[low]=num[high]; while(low< high&&num[low]<=key) ++low; num[high]=num[low]; } num[low]=key; //递归 quick_sort(num,left,low-1); quick_sort(num,low+1,right);}
}
int main(void)
{
int num[9]={2,5,9,1,7,3,18,20,11};quick_sort(num,0,8);for(int i=0;i<9;++i)return 0;
}
0 0
- 快速排序
- 快速排序
- 快速排序
- 快速排序!
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- 快速排序
- STLINK找不到debug session的解决办法
- C#中的线程
- PopupWindow简单使用
- 欢迎使用CSDN-markdown编辑器
- 【资源分享】GitHub For Windows 2.14.7.1 压缩版下载(解压后,270M)
- 快速排序
- 3D游戏编程-第一个游戏
- linux下解压缩*.tar.xz方法
- Android强制切换横屏竖屏不起作用的解决办法
- iOS KVO概述及用法
- iOS 移动开发月报-第1期
- 黑马程序员--Java--正则和反射
- SVN服务器搭建和使用(一)
- ORACLE統計信息收集