思考与总结:
1.优先队列,先出队列元素不是先进队列的元素,而是队列中优先级最高的元素
2.遇到这种题一般把每一个数据封装到一个struct里
3.然后根据优先级判断依据,我们通过重定向定义优先队列的优先级
如果我们写bool operator <
下面return里a< b,意味着a的值比b小的话,优先级小
4.我们把数据输入优先队列里,那队列里就自动为我们排好序了
输出的时候,取队列顶端,就把优先级大的取出来了
题目1:
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