当前位置:网站首页>力扣刷题记录--常用功能函数
力扣刷题记录--常用功能函数
2022-08-09 01:51:00 【@白圭】
目录
一、快速排序
//快速排序算法
void quick_sort(vector<int>& nums,int start,int end)
{
if(start < end)
{
//常规变量
int i;
//
int base=nums[start];//以要进行排序数组第0个元素为base
int left=start;//左指针
int right=end;//右指针
while(left<right)
{
//从右向左找,比base大,right--
while(left<right&&nums[right]>=base)
{
right--;
}
//找比base校,替换left所在位置的数字
nums[left]=nums[right];
//从左向右找,比base小,left++
while(left<right&&nums[left]<=base)
{
left++;
}
//比base大,替换right所在位置的数字
nums[right]=nums[left];
}
nums[left]=base;//此时left=right,用base替换这个位置的数字
// for(i=0;i<=4;i++)
// std::cout<<" i in "<<nums[i]<<std::endl;
//递归调用
quick_sort(nums,start,left-1);
quick_sort(nums,left+1,end);
}
}
边栏推荐
猜你喜欢

考研人总结的时间管理7大忌,你中了几条?

『Another Redis DeskTop Manager』用了这款Redis可视化工具,分析效率提升12倍

全文翻译:EDPB 基于设计和默认的数据保护指南

Loadrunner结合Fiddler实现脚本的录制

2022PMP项目管理认证考试报考指南(1)

HCIP-R&S By Wakin自用笔记(3)OSPF之各类LSA及LSA更新规则

torchversion.transforms的使用
![[Signal denoising] Based on Sage-Husa adaptive Kalman filter to realize the suppression of ocean wave magnetic field noise and the generation of ocean wave magnetic field noise with matlab code](/img/4d/df77e7610fa9065456b12cece9e6de.png)
[Signal denoising] Based on Sage-Husa adaptive Kalman filter to realize the suppression of ocean wave magnetic field noise and the generation of ocean wave magnetic field noise with matlab code

ICMP差错报告报文数据字段

任务五 处理连续型数据
随机推荐
如何准备一份简历
如何在EasyDSS中使用ffmpeg实现点播视频的拼接与合成?
[Signal denoising] Based on Sage-Husa adaptive Kalman filter to realize the suppression of ocean wave magnetic field noise and the generation of ocean wave magnetic field noise with matlab code
JDBC技术(二)——设置通用的sql和配置文件
【信号去噪】基于Sage-Husa自适应卡尔曼滤波器实现海浪磁场噪声抑制及海浪磁场噪声的产生附matlab代码
睿智的目标检测61——Tensorflow2 Focal loss详解与在YoloV4当中的实现
考研人总结的时间管理7大忌,你中了几条?
Go-11-流程控制
《LC刷题总结》—— 二叉树
德语翻译-德语在线批量翻译软件
SEMRush如何寻找关键词用于投放广告
智能视频监控设计摄像头部分
Qt中QFile、QByteArray QDataStream和QTextStream区别
Introduction to LVGL (based on v8.1-8.2)
《LC刷题总结》——贪心
Group DETR:分组一对多匹配是加速DETR收敛的关键
企业里Foxmail邮箱问题解决方法汇总
Proe/Creo智能硬件产品结构设计要点「干货分享」
2022护眼产品展,北京眼健康展,眼科医学展,近视矫正设备展
qps tps rps 区别