#include <iostream>
#include <algorithm>
#include <stack>
using namespace std;
class My_queue {
private:
stack<int> data;
public:
void push(int x) {
stack<int> tmp_data;
while (!data.empty())
{
tmp_data.push(data.top());
data.pop();
}
tmp_data.push(x);
while (!tmp_data.empty())
{
data.push(tmp_data.top());
tmp_data.pop();
}
}
int pop() {
int x = data.top();
data.pop();
return x;
}
/*返回队列头部元素*/
int peek() {
return data.top();
}
bool empty() {
return data.empty();
}
};
int main() {
My_queue q;
cout << "construct the queue " << endl;
int tmp;
for (int i = 0;i < 5; ++i){
cin >> tmp;
q.push(tmp);
}
cout << "pop " << q.pop() << endl;
cout << "peek " << q.peek() << endl;
q.push(10);
cout << "peek push '10' " << q.peek() << endl;
return 0;
}