在pair<int,int>的second中进行排序
作者:
Soel
,
2023-01-23 19:43:27
,
所有人可见
,
阅读 153
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
vector<pair<int,int>> a(10+1);
for (int i = 1; i <= 10; i++) cin >> a[i].second;
sort(a.begin() + 1, a.end(), [](const auto& b1, const auto& b2)->bool {
return b1.second < b2.second;
});
//cout << &a[0].second << ' ' << &a[1].second << ' ';
//for (auto c : a) cout << c.second << ' ';
for (int i = 1; i <= 10; i++) cout << a[i].second << ' ';
cout << '\n';
return 0;
}