AcWing
  • 首页
  • 活动
  • 题库
  • 竞赛
  • 更多
    • 题解
    • 分享
    • 问答
    • 应用
  • App
  • 教育优惠
    New
  • 登录/注册

在pair<int,int>的second中进行排序

作者: 作者的头像   Soel ,  2023-01-23 19:43:27 ,  所有人可见 ,  阅读 153


0


#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;
}

0 评论

你确定删除吗?
1024
x

© 2018-2023 AcWing 版权所有  |  京ICP备2021015969号-2
用户协议  |  隐私政策  |  常见问题  |  联系我们
AcWing
请输入登录信息
更多登录方式: 微信图标 qq图标 qq图标
请输入绑定的邮箱地址
请输入注册信息