如何cmp函数应用在STL中?
  • 板块灌水区
  • 楼主Martlet
  • 当前回复5
  • 已保存回复5
  • 发布时间2023/1/14 17:38
  • 上次更新2023/10/24 04:16:16
查看原帖
如何cmp函数应用在STL中?
543717
Martlet楼主2023/1/14 17:38

STL对结构中的排序规则一般写在结构体中

struct fl{
	int w,c;
	bool operator <(const fl &s) const {
        return c<s.c;
        
    }
};

set<fl> a;
	
}

那能不能写一个cmp函数进行排序

struct fl{
	int w,c;
	
};
bool cmp(fl a,fl b){
   return a.w<b.w;
}

如何将这个cmp函数应用在STL中?

2023/1/14 17:38
加载中...