Ejemplo n.º 1
0
	T pop()
	{//出队
		if (B.empty())
		{//若B空,则队首元素应该在A的栈底
			while (!A.empty())//将A中元素全部压入B
				B.push(A.pop());
		}
		return B.pop();//出B栈
	}
Ejemplo n.º 2
0
	void pop()
	{
		if (head.empty())
		{
			while (!tail.empty())
			{
				head.push(tail.top());
				tail.pop();
			}
		}
		head.pop();
	}
Ejemplo n.º 3
0
	void push(const T & val) { A.push(val); }
Ejemplo n.º 4
0
	void push(const int& x)
	{
		tail.push(x);
	}