-->
当前位置:首页 > 题库

PROGRAMMING:Windows message queuing

Luz5年前 (2021-05-10)题库471
Message queue is the foundation of windows system. For each process, the system maintains a message queue. If specific events occur in the process, such as mouse click, text change, etc., the system will add the message to the queue. At the same time, if the queue is not empty, the process circularly gets messages from the queue according to priority. Note that a low priority value means a high priority. Please edit the program to simulate the message queue, add the message to the queue and get the message from the queue.
###Input format:
The input first gives a positive integer n ($$\ le10 ^ 5 $$), and then n lines. Each line gives an instruction --'Get 'or'put', which respectively means to remove messages from the queue or add messages to the queue. If the instruction is' put ', there will be a message name and a positive integer to indicate the priority of the message. The smaller the number, the higher the priority. The message name is a string with no more than 10 characters and no spaces; The title ensures that the priority of messages in the queue is not duplicate, and the input has at least one 'get'.
###Output format:
For each 'get' instruction, the name and parameters of the message with the highest priority in the message queue are output in one line. If there is no message in the message queue, output "empty queue!". For the 'put' instruction, there is no output.
###Input example:
```in
nine
PUT msg1 5
PUT msg2 4
GET
PUT msg3 2
PUT msg4 4
GET
GET
GET
GET
```
###Output example:
```out
msg2
msg3
msg4
msg1
EMPTY QUEUE!
```






answer:If there is no answer, please comment