资阳建设机械网站,海口网约车最新政策,健身网站开发方式,快速做网站套餐Acwing 828. 模拟栈 题目要求思路讲解代码展示 题目要求 思路讲解 栈#xff1a;先进后出 队列#xff1a;先进先出 代码展示
#include iostreamusing namespace std;const int N 100010;int m;
int stk[N], tt;int main()
{cin m;while (m -- ){string o… Acwing 828. 模拟栈 题目要求思路讲解代码展示 题目要求 思路讲解 栈先进后出 队列先进先出 代码展示
#include iostreamusing namespace std;const int N 100010;int m;
int stk[N], tt;int main()
{cin m;while (m -- ){string op;int x;cin op;if (op push){cin x;stk[ tt] x;}else if (op pop) tt -- ;else if (op empty) cout (tt ? NO : YES) endl;else cout stk[tt] endl;}return 0;
}