您当前的位置: 首页 >  c++

C++ std::vector 自定义排序

软件工程小施同学 发布时间:2021-11-05 11:07:11 ,浏览量:3

#include
#include
#include
#include
using namespace std;

typedef struct rect
{
    string name;
    int id;
    int length;
    int width;

    //对于向量元素是结构体的,可在结构体内部定义比较函数,下面按照id,length,width升序排序。
    bool operator< (const rect &a)  const
    {
        if(id!=a.id)
            return id            
关注
打赏
1688896170
查看更多评论
0.0527s