2020.3.30美团一面面试题:
1.数据结构–给定两个栈实现队列的存取元素
#include <bits/stdc++.h>
//#include <iostream>
//#include <stack>
using namespace std;
class Solution{
public:
stack<int> stac1;
stack<int> stac2;
void mypush(int a){
stac1.push(a);
}
void mypop(){
if(stac1.empty() && stac2.empty())
cout<<"队列为空"<<endl;//代表队列为空
if(stac2.empty())
{
while(!stac1.empty())
{
int temp=stac1.top();
stac2.push(temp);
stac1.pop();
}
}
cout<< stac2.top()<<endl;
stac2.pop();
}
};
int main() {
//int a;
//cin >> a;
Solution s;
s.mypush(1);
s.mypush(2);
s.mypop();
s.mypush(3);
s.mypop();
s.mypop();
return 0;
}
2.TCP/IP协议
a.TCP三次握手四次挥手–具体实现过程
三次握手: 注意客户端和服务端的状态变化
四次挥手: 注意客户端和服务端的状态变化
3.HTTP的报文格式:
4.reactor模式
单reactor模式
多reactor模式
详情参考:
https://www.cnblogs.com/winner-0715/p/8733787.html