博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Windows Message Queue
阅读量:5788 次
发布时间:2019-06-18

本文共 2087 字,大约阅读时间需要 6 分钟。

Message queue is the basic fundamental of windows system. For each process, the system maintains a message queue. If something happens to this process, such as mouse click, text change, the system will add a message to the queue. Meanwhile, the process will do a loop for getting message from the queue according to the priority value if it is not empty. Note that the less priority value means the higher priority. In this problem, you are asked to simulate the message queue for putting messages to and getting message from the message queue.

 

Input

 

There's only one test case in the input. Each line is a command, "GET" or "PUT", which means getting message or putting message. If the command is "PUT", there're one string means the message name and two integer means the parameter and priority followed by. There will be at most 60000 command. Note that one message can appear twice or more and if two messages have the same priority, the one comes first will be processed first.(i.e., FIFO for the same priority.) Process to the end-of-file.

<b< dd="">

Output

 

For each "GET" command, output the command getting from the message queue with the name and parameter in one line. If there's no message in the queue, output "EMPTY QUEUE!". There's no output for "PUT" command.

<b< dd="">

Sample Input

 

GETPUT msg1 10 5PUT msg2 10 4GETGETGET

<b< dd="">

Sample Output

 

EMPTY QUEUE!msg2 10msg1 10EMPTY QUEUE!

 

#include
#include
#include
#include
using namespace std;struct kang{ char k[220]; int a, b, c;};map
ko;bool operator < (const kang & a, const kang & b){ if (a.b != b.b) return a.b > b.b; return a.c > b.c;}int main(){ priority_queue
k; char str[10]; while (cin >> str) { if (str[0] == 'G') { if (k.empty()) cout << "EMPTY QUEUE!" << endl; else { kang kg; kg = k.top(); k.pop(); cout << kg.k <<" "<< kg.a << endl; } } else { kang kg; cin >> kg.k >> kg.a >> kg.b; kg.c = ko[kg.b]++; k.push(kg); } } return 0;}

 

转载于:https://www.cnblogs.com/kangdong/p/8454913.html

你可能感兴趣的文章
struts2中form提交到action中的中文参数乱码问题解决办法(包括取中文路径)
查看>>
25 个精美的手机网站模板
查看>>
C#反射实例应用--------获取程序集信息和通过类名创建类实例
查看>>
VC中实现文字竖排的简单方法
查看>>
会话标识未更新
查看>>
阿里架构师:程序员必须掌握的几项核心技术能力
查看>>
程序员常用的六大技术博客类
查看>>
Iceworks 2.8.0 发布,自定义你的 React 模板
查看>>
胖哥学SpringMVC:请求方式转换过滤器配置
查看>>
Kotlin 更加优雅的 Builder - 理解 with
查看>>
前端日拱一卒D6——字符编码与浏览器解析
查看>>
深入理解浏览器的缓存机制
查看>>
微软向Linux社区开放60000多项专利:对开源微软是认真的
查看>>
Hoshin Kanri在丰田的应用
查看>>
又拍云沈志华:如何打造一款安全的App
查看>>
克服大数据集群的挑战
查看>>
PostgreSQL并发控制(MVCC, 事务,事务隔离级别)
查看>>
DM***的第二阶段OSPF
查看>>
20180702搭建青岛RAC记录
查看>>
Spring Security OAuth 实现OAuth 2.0 授权
查看>>