class MyStack {
public:
queue<int> qu;
MyStack() {
}
void push(int x) {
qu.push(x);
}
int pop() {
int size = qu.size();
size--;//只剩一个数的时候不用变换
while (size--){
qu.push(qu.front());//将队列头部的放到队列末尾
qu.pop();
}
int result = qu.front();
qu.pop();
return result;
}
int top() {
return qu.back();
}
bool empty() {
return qu.empty();
}
};
/**
* Your MyStack object will be instantiated and called as such:
* MyStack* obj = new MyStack();
* obj->push(x);
* int param_2 = obj->pop();
* int param_3 = obj->top();
* bool param_4 = obj->empty();
*/