优先队列
2016-03-29 12:13
190 查看
#include <iostream> #include <stdio.h> #include<string.h> #include <queue> using namespace std; struct node { int a,b; friend bool operator <(node x,node y) { return x.a>y.a; //如果为 >优先级小的先出队列 反之 } }; priority_queue<node> q; int main() { node a[10]; for(int i=0; i<10; i++) { scanf("%d %d",&a[i].a,&a[i].b); q.push(a[i]); node b; b=q.top(); printf(">>>%d %d\n",b.a,b.b); } return 0; }
</pre><pre name="code" class="cpp">
出队列按照一定优先级出队列 ,见下图
图一 图二
相关文章推荐
- IOS开发前的准备
- java使用POI jar包读写xls文件
- HTML5[5]:在移动端禁用长按选中文本功能
- How can enable udev sync successfully in docker?
- NFS共享MySQL使用DNS轮询实现Web负载均衡 推荐
- sql语句查询执行顺序
- iOS之解决UITableView与背景颜色不一致问题
- 并查集备忘录
- ODB-Oracle填坑
- 杂记
- Codeforces 652E Pursuit For Artifacts 【边双连通 缩点】
- clean后R.java不见了
- Hadoop完全分布式集群安装
- 安装SQL Server提示“重叠的IO操作正在进行”解决
- Codeforces 652D Nested Segments 【树状数组 + 离散化】
- android中.9.png的认识
- Codeforces 652C Foe Pairs 【dp】
- cJSON的构造和解析
- 使用jsonp实现ajax跨域请求
- codeforce 658C Bear and Forgotten Tree 3