标签:rbegin tor ret key code col fir class span
//vector的排序 vector<int>v; sort(v.begin(),v.end());升序 sort(v.rbegin(),v,rend());降序 //sort of vector<pair<int,int> >v; v.push_back({1,5}); v.push_back({2,3}); v.push_back({1,2}); sort(v.begin(), v.end());//输出{1,2},{1,5},{2,3} //sort of vecto<tuple<int,int,int> > v; v.push_back({2,1,4}); v.push_back({1,5,3}); v.push_back({2,1,3}); sort(v.begin(), v.end()); //有is~
vector<pair<int,int> >v;很常用
还有一种写法
1 void cmp(pair<int,int> a,pair<int,int> b) 2 { 3 if(a.first==b.first)return a.second<s.b.second; 4 5 return a.first<b.first; 6 } 7 8 9 10 pair<int,int> a,pair<int,int> b; 11 12 sort(a,b,cmp);
//string bool comp(string a, string b) { if (a.size() != b.size()) return a.size() < b.size(); return a < b; } string s="monkey"; sort(s.begin(),s.end());//output:ekmnoy
标签:rbegin tor ret key code col fir class span
原文地址:https://www.cnblogs.com/guaguastandup/p/10343113.html