优先队列
来源:互联网 发布:前端数据库 编辑:程序博客网 时间:2024/05/22 10:47
优先队列:普通队列具有先进先出的特点,优先队列出队时具有优先级别
#include<cstdio>
#include<queue>
using namespace std;
struct num1
{
int time;
bool operator < (const num1 &a)
const
{
return time>a.time; //按最小值优先
}
};
struct num2
{
int time;
bool operator < (const num2 &a)
const
{
return time<a.time; // 按最大值优先
}
};
int main()
{
num2 b;
int n;
priority_queue<num2> mm;
printf("please input n number\n");
scanf("%d",&n);
while(n--)
{
scanf("%d",&b);
mm.push(b);
}
while(!mm.empty())
{
num2 bb=mm.top();
printf("%d ",bb.time);
mm.pop();
}
return 0;
}
*/
/*#include<cstdio>
#include<queue>
#include<vector>
using namespace std;
struct cmp1
{
bool operator()(int &a,int &b)
{
return a>b; //按最小值优先
}
};
struct cmp2
{
bool operator()(int &a,int &b)
{
return a<b; //按最大值优先
}
};
int main()
{
priority_queue<int,vector<int>,cmp2> mm;
int n,a;
printf("please input n number\n");
scanf("%d",&n);
while(n--)
{
scanf("%d",&a);
mm.push(a);
}
while(!mm.empty())
{
int b=mm.top();
printf("%d ",b);
mm.pop();
}
return 0;
}
*/
- 优先队列
- 优先队列
- 优先队列
- 优先队列
- 优先队列
- 优先队列
- 优先队列
- 优先队列
- 优先队列
- 优先队列
- 优先队列
- 优先队列
- 优先队列
- 优先队列
- 优先队列
- 优先队列
- 优先队列
- 优先队列
- 国内存储企业可在大数据时代“分一杯羹”
- maven中jar不同版本的依赖
- DXSDK Error S1023
- 黑马程序员20.网络编程
- 上传图片图像进行压缩后上传
- 优先队列
- IOS之Quartz2D绘图6.PDF文档生成
- KDiff3-文件分析、合并工具
- arm11 和A9
- Hbase 启动报错 class org.apache.hadoop.hbase.master.HMaster
- FileZilla——425 Can't open data connection
- Java对象创建方式及JVM对字符串处理
- IOS:ASIHttpRequest学习1
- 1407241612-hd-ASCII码排序.cpp