cpp优先队列

#include
#include
#include
using namespace std;

struct fruit{
	string name;
	int price;
	friend bool operator < (fruit f1, fruit f2){
		return f1.price > f2.price; // 价格高的优先级低 
	}
}f1,f2,f3;

int main(){
	priority_queue q;
	f1.name = "桃子";
	f1.price = 3;
	f2.name = "梨子";
	f2.price = 4;
	f3.name = "苹果";
	f3.price = 1;
	
	q.push(f1);
	q.push(f2);
	q.push(f3);
	cout<

你可能感兴趣的:(c++数据结构)