sort函数

用到了快速排序、插入、堆排序。

 1 #include <algorithm>
 2 
 3 vector<int> vc;
 4 sort(vc.begin(),vc.end(),less<int>());//默认升序排序
 5 sort(vc.begin(),vc.end(),greater<int>());//降序排序
 6 
 7 or
 8 vector<int> vc;
 9 bool cmp(const int& a, const int& b){
10     return a<b;//升序
11 }
12 sort(vc.begin(),vc.end(),cmp);//升序

 

posted @ 2019-06-09 16:09  Austin_anheqiao  阅读(255)  评论(0编辑  收藏  举报