class CQueue {
public:
stack<int> a;
stack<int> b;
CQueue() {
}
void appendTail(int value) {
a.push(value);
}
int deleteHead() {
if(a.empty()&&b.empty())return -1;
else if(!b.empty())
{
}else if(!a.empty())
{
while(!a.empty())
{
b.push(a.top());
a.pop();
}
}
int val=b.top();
b.pop();
return val;
}
};
/**
* Your CQueue object will be instantiated and called as such:
* CQueue* obj = new CQueue();
* obj->appendTail(value);
* int param_2 = obj->deleteHead();
*/
只要b不空,就输出