
本文共 2489 字,大约阅读时间需要 8 分钟。
���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������:
���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������
������������
������������������������������������������������������������������������������������������
���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������
������������
#includeusing namespace std;class MyStack {private: queue q;public: void push(int x) { // ��������������������������������������� int temp = 0; int size = q.size(); while (size--) { temp = q.front(); q.pop(); } q.push(temp); // ������������������ q.push(x); // ������������������ } int pop() { return q.front(); q.pop(); } int top() { return q.front(); } bool empty() { return q.empty(); }};
���������������������������
���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������
��������������������������������� O(1)������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������
发表评论
最新留言
关于作者
