Example #1
0
	T pop()
	{//出队
		if (B.empty())
		{//若B空,则队首元素应该在A的栈底
			while (!A.empty())//将A中元素全部压入B
				B.push(A.pop());
		}
		return B.pop();//出B栈
	}
	void pop()
	{
		if (head.empty())
		{
			while (!tail.empty())
			{
				head.push(tail.top());
				tail.pop();
			}
		}
		head.pop();
	}