队列实现栈

class Stack {
private:
    queue<int> que;
public:
    // Push element x onto stack.
    void push(int x) {
        que.push(x);
    }
    
    // Removes the element on top of the stack.
    void pop() {
        queue<int> popedQue;
        auto len = que.size();
        for (size_t i = 0; i < len - 1; ++i){
            popedQue.push(que.front());
            que.pop();
        }
        que = popedQue;
        // pop que except tail
        // then que = popedQue
    }
    
    // Get the top element.
    int top() {
        return que.back();
    }
    
    // Return whether the stack is empty.
    bool empty() {
        return que.empty();
    }
};