直接选择排序1.0

来源:互联网 发布:西安华为算法工程师 编辑:程序博客网 时间:2024/06/05 02:50
<span style="font-family:Comic Sans MS;font-size:18px;">//selectSort.h<span id="transmark"></span>#include<iostream>#include<vector>using namespace std;template<typename T>void selectSort(vector<T> &v){for(auto i=v.begin();i!=v.end()-1;i++){for(auto n=i+1;n!=v.end();n++){if(*n<*i)swap1(*n,*i);}}}template<typename T>void swap1(T &a,T &b){auto temp=a;a=b;b=temp;}template<typename T>void show(vector<T> &v){for(auto p:v)cout<<p<<endl;}</span>

0 0
原创粉丝点击