您的位置:首页 > 产品设计 > UI/UE

priority_queue中cmp函数的用法

2018-03-15 13:37 323 查看
#include "stdafx.h"
#include<cstdio>
#include<iostream>
#include<vector>
#include<cstring>
#include<queue>

using namespace std;
const int maxn=100;
struct node{
int val;
node(int val):val(val){}

};
struct cmp{
bool operator()(node a,node b){
return a.val<b.val;
}
};

int main(){

freopen("c://jin.txt","r",stdin);
priority_queue<node,vector<node>,cmp>q;
q.push(node(1));
q.push(node(2));
q.push(node(3));
while(!q.empty()){

cout<<q.top().val<<endl;q.pop();

}

freopen("CON","r",stdin);
system("pause");
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: