结构体的运算符重载
  • 板块灌水区
  • 楼主MARCUSE
  • 当前回复2
  • 已保存回复2
  • 发布时间2024/7/20 09:31
  • 上次更新2024/7/20 10:35:44
查看原帖
结构体的运算符重载
199051
MARCUSE楼主2024/7/20 09:31
#include <bits/stdc++.h>
using namespace std;
struct node{
	int x,y;
	bool operator <(node a,node b) {
	    return a.x > b.x;
	}
};	
priority_queue <node> q;
int main(){
    q.push(node{2,0});
	q.push(node{1,1});
	while(!q.empty()){
		cout << q.top().x << " " << q.top().y << endl;
		q.pop();
	}	
	return 0;
}

忘掉怎么写了

救救救救救

2024/7/20 09:31
加载中...