没有合适的资源?快使用搜索试试~ 我知道了~
快速排序算法,纯文本代码
资源推荐
资源详情
资源评论
//快速排序
#include<iostream>
using namespace std;
int partition(int *arr,int low,int high)
{
int pivotkey=arr[low];
while(low<high)
{
while(low<high&&arr[high]>=pivotkey)
--high;
arr[low]=arr[high];
while(low<high&&arr[low]<=pivotkey)
++low;
arr[high]=arr[low];
}
arr[low]=pivotkey;
return low;
}
void sort(int *arr,int low,int high)//通过递归函数进行快速排序
{
if(low<high)
{
int pivot=partition(arr,low,high);
sort(arr,low,pivot-1);
sort(arr,pivot+1,high);
}
}
int sortNum(int *arr,int s,int t,int seq)//通过快速排序 搜索出第seq个数
{
int low=s;
#include<iostream>
using namespace std;
int partition(int *arr,int low,int high)
{
int pivotkey=arr[low];
while(low<high)
{
while(low<high&&arr[high]>=pivotkey)
--high;
arr[low]=arr[high];
while(low<high&&arr[low]<=pivotkey)
++low;
arr[high]=arr[low];
}
arr[low]=pivotkey;
return low;
}
void sort(int *arr,int low,int high)//通过递归函数进行快速排序
{
if(low<high)
{
int pivot=partition(arr,low,high);
sort(arr,low,pivot-1);
sort(arr,pivot+1,high);
}
}
int sortNum(int *arr,int s,int t,int seq)//通过快速排序 搜索出第seq个数
{
int low=s;
资源评论
宋亚
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- TG-2024-05-23-204718255.mp4
- 候志强@181 5428 8938_20240420112107.amr
- spispispispispi
- 实验二:IP协议分析.zip
- 驱动代码驱动代码驱动代码驱动代码
- SVID_20240523_141155_1.mp4
- Code for the complete guide to tkinter tutorial
- 关于百货中心供应链管理系统.zip
- SimpleFolderIcon-master 修改Unity的Project下的文件夹图标
- A python Tkinter widget to display tile based maps
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功