HDU1509 FLY

Problem Description

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.

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.

Sample Input

GET
PUT msg1 10 5
PUT msg2 10 4
GET
GET
GET

Sample Output

EMPTY QUEUE!
msg2 10
msg1 10
EMPTY QUEUE!

.此程序C++不通过,G++通过

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <queue>
using namespace std;
struct node{
	string name;
	int mes;
	int priority;
	int num;
	friend bool operator<(node a, node b){
		if(a.priority!=b.priority){
			return a.priority>b.priority;
		}
		return a.num>b.num;
	}
};
int main(){
	priority_queue<node>q;
	node fir, next;
	string str;
	int k=0;
	while(cin>>str){
		if(str=="GET"){
			if(q.empty()){
				cout<<"EMPTY QUEUE!"<<endl;
			}
			else {
				fir=q.top();
				q.pop();
				cout<<fir.name<<" "<<fir.mes<<endl;
			}
		}
		else{
			cin>>next.name>>next.mes>>next.priority;
			next.num=k++;
			q.push(next);
		}
	}
	return 0;
}

程序原链接https://blog.youkuaiyun.com/hjd_love_zzt/article/details/9821043?depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromBaidu-1&utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromBaidu-1

1.为什么有friend?
类的友元函数是定义在类外部,但有权访问类的所有私有(private)成员和保护(protected)成员。尽管友元函数的原型有在类的定义中出现过,但是友元函数并不是成员函数。

友元可以是一个函数,该函数被称为友元函数;友元也可以是一个类,该类被称为友元类,在这种情况下,整个类及其所有成员都是友元。

如果要声明函数为一个类的友元,需要在类定义中该函数原型前使用关键字 friend,
我理解为如果结构体内部要调用结构体就要加friend,朋友关系。
友元函数https://www.runoob.com/cplusplus/cpp-friend-functions.html

2.operator?
operator是C++的关键字,它和运算符一起使用,表示一个运算符函数,理解时应将operator=整体上视为一个函数名版。这是C++扩展运算符功能的方法,虽然样子古怪,但也可以理解:一方权面要使运算符的使用方法与其原来一致,另一方面扩展其功能只能通过函数的方式(c++中,“功能”都是由函数实现的)。

3.优先队列
在题中优先级值越小优先级越大。程序中
if(a.priority!=b.priority){
return a.priority>b.priority;
}
return a.num>b.num;
}
随着输入,num值增大。
当priority相同时小的出,不相同时,priority小的出。
所以我认为这是个排序始终把priority大的放在刚入入的地方就是队尾,相同时num值大的放在队尾。反过来说就是优先级值小的在对头先输出。

内容概要:本文深入剖析了HTTPS中SSL/TLS握手的全流程,系统讲解了HTTPS的诞生背景及其相较于HTTP在安全性上的优势,重点阐述了SSL/TLS握手各阶段的技术细节,包括ClientHello、ServerHello、证书交换、密钥交换及加密通信建立等环节。文章结合加密基础概念(对称加密、非对称加密、哈希算法)和数字证书机制,解释了数据加密、身份验证与完整性保护的实现原理,并通过Wireshark抓包实例帮助读者直观理解握手过程中的数据交互。同时,归纳了常见握手失败问题及其解决方案,最后对SSL/TLS未来发展趋势进行了展望,涵盖抗量子加密算法和高效协议优化方向。; 适合人群:具备基本网络和安全知识的开发人员、运维工程师、网络安全爱好者,以及希望深入理解HTTPS底层机制的技术从业者;尤其适合1-3年经验、正在向中高级岗位发展的技术人员。; 使用场景及目标:①掌握HTTPS工作原理及SSL/TLS握手全过程,理解加密通信建立机制;②能够分析和排查HTTPS连接中的证书、加密套件、版本兼容等问题;③通过抓包实践提升对网络安全协议的实际分析能力;④为后续学习TLS 1.3、零RTT、前向保密等高级主题打下坚实基础; 阅读建议:此资源理论与实践结合紧密,建议在学习过程中同步使用Wireshark等工具进行抓包实验,对照文档中的握手阶段逐一验证各消息内容,加深对加密协商、证书验证和密钥生成过程的理解。同时关注最新TLS版本的发展趋势,拓展安全视野。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值