【 声明:版权所有,转载请标明出处,请勿用于商业用途。 联系信箱:libin493073668@sina.com】
题意:
使用队列来模拟栈
思路:
使用双向队列能够很完美的实现
class Stack
{
deque<int> in;
public:
// Push element x onto stack.
void push(int x)
{
in.push_back(x);
}
// Removes the element on top of the stack.
void pop()
{
in.pop_back();
}
// Get the top element.
int top()
{
return in.back();
}
// Return whether the stack is empty.
bool empty()
{
return in.empty();
}
};