<span style="font-family:Comic Sans MS;font-size:18px;">//quickSort.h
#include<iostream>
#include <vector>
using namespace std;
template<typename T>
void quickSort(vector<T> &v,int begin,int end){
int i=begin;
int j=end;
if(i<j){
for(;i!=j;){
if(v[i]>v[j]){
swap1(v[i],v[j]);
i++;
}
else
j--;
}
quickSort(v,0,i-1);
quickSort(v,j+1,end);
}
}
template<typename T>
void swap1(T &a,T &b){
T temp=a;
a=b;
b=temp;
}
template<typename T>
void show(vector<T> &v){
for(auto p:v)
cout<<p<<endl;
}</span>递归的思想确实很有用,加油!快速排序1.0
最新推荐文章于 2023-08-28 20:17:15 发布
783

被折叠的 条评论
为什么被折叠?



