剑指 Offer 09. 用两个栈实现队列(简单)
题目:

class CQueue {
public:
stack<int> st1;
stack<int> st2;
CQueue() {
}
void appendTail(int value) {
st1.push(value);
}
int deleteHead() {
if(st1.empty()&&st2.empty())return -1;
if(!st2.empty()){ //要先从st2中弹出队列头部元素
int top=st2.top();
st2.pop();
return top;
}
while(!st1.empty()){ //st2为空的时候再把st1中元素全部导入st2中,此后再弹出队列头部元素
st2.push(st1.top());
st1.pop();
}
int top=st2.top();
st2.pop();
return top;
}
};