您当前的位置: 首页 >  c++
  • 0浏览

    0关注

    1477博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

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

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

#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            
关注
打赏
1665320866
查看更多评论
0.0416s