链接:https://leetcode-cn.com/problems/yong-liang-ge-zhan-shi-xian-dui-lie-lcof/
代码:
class CQueue { public: stack<int> stack_a; stack<int> stack_b; CQueue() { } void appendTail(int value) { stack_a.push(value); } int deleteHead() { if (stack_a.empty() && stack_b.empty()) return -1; else if (stack_b.empty() && !stack_a.empty()) { while (!stack_a.empty()) { stack_b.push(stack_a.top()); stack_a.pop(); } } int temp = stack_b.top(); stack_b.pop(); return temp; } };