2088-数据结构实验之栈与队列十一:refresh的停车场
来源:互联网 发布:淘宝官方店是正品吗 编辑:程序博客网 时间:2024/06/05 19:53
#include <bits/stdc++.h>using namespace std;int main(){ int n,t; while(cin >> n >> t) { stack<long long>S; queue<long long>Q; char st[10]; int flag = 1; int m = 0; while(t--) { long long num; cin >> st; if(strcmp(st,"Add") == 0) { cin >> num; if(m < n) { S.push(num); m++; } else Q.push(num); } else if(strcmp(st,"Del") == 0) { if(S.empty()) flag = 0; else { S.pop(); m--; } } else if(strcmp(st,"Out") == 0) { if(Q.empty()) { flag = 0; } else Q.pop(); } while(!Q.empty() && m < n) { long long x; x = Q.front(); Q.pop(); S.push(x); m++; } } if(flag) { while(!S.empty()) { cout << S.top() << endl; S.pop(); } } else cout << "Error" << endl; } return 0;}
阅读全文
0 0
- 数据结构实验之栈与队列十一:refresh的停车场
- 数据结构实验之栈与队列十一:refresh的停车场
- 数据结构实验之栈与队列十一:refresh的停车场
- 数据结构实验之栈与队列十一:refresh的停车场
- 数据结构实验之栈与队列十一:refresh的停车场
- 数据结构实验之栈与队列十一:refresh的停车场
- 数据结构实验之栈与队列十一:refresh的停车场
- 数据结构实验之栈与队列十一:refresh的停车场
- sdut 2088 数据结构实验之栈与队列十一:refresh的停车场
- 2088-数据结构实验之栈与队列十一:refresh的停车场
- 队列实验refresh的停车场
- 栈与队列--refresh的停车场
- [SDUT](2088)refresh的停车场 ---栈和队列
- refresh的停车场 (栈+队列)
- refresh的停车场(栈+队列)
- 2088-->refresh的停车场
- refresh的停车场(栈和队列的STL)
- 栈和队列的使用 refresh的停车场
- 数据库系统原理常用SQL语句
- 2449-数据结构实验之栈与队列十:走迷宫
- 集训Day1 T1 青蛙 (jump)
- 鱼眼镜头的选型
- KMP算法的理解
- 2088-数据结构实验之栈与队列十一:refresh的停车场
- 在java中浅谈Math类中的常用方法
- latex中的箭头
- Xshell中输入rz提示:-bash: rz: command not found
- Oracle连接配置文件 tnsnames
- SQL优化
- 1029. 旧键盘(20)
- 1042. 字符统计(20)
- ajax删除成功后局部刷新