hdu 1702
来源:互联网 发布:离线运行unity3d游戏 编辑:程序博客网 时间:2024/06/07 15:09
题目大意:理解起来很简单,读者可以直接上OJ上面看
代码如下:
/* * 1702_1.cpp * * Created on: 2013年8月7日 * Author: Administrator * 为了能有章泽天这样的女朋友而不断努力。。。。 */#include <iostream>#include <stack>#include <queue>using namespace std;int main() {int t, m;string str;cin >> t;stack<int> p;queue<int> q;while (t--) {/** * 因为STL中的stack、queue没有专门的clear()函数 * 所以每次都要自己写清空stack、queue的函数 */while(!p.empty()){p.pop();}while(!q.empty()){q.pop();}cin >> m >> str;if (str == "FIFO") {for (int i = 0; i < m; ++i) {string cmd;int n;cin >> cmd;if (cmd == "IN") {cin >> n;q.push(n);} else if (cmd == "OUT") {if (!q.empty()) {int a = q.front();q.pop();cout << a << endl;} else {cout << "None" << endl;}}}} else {for (int i = 0; i < m; ++i) {string cmd;int n;cin >> cmd;if (cmd == "IN") {cin >> n;p.push(n);} else if (cmd == "OUT") {if (!p.empty()) {int a = p.top();p.pop();cout << a << endl;} else {cout << "None" << endl;}}}}}}
- HDU 1702
- hdu 1702
- HDU 1702
- HDU-1702
- HDU 1702
- hdu 1702 暴力
- hdu 1702 水水
- HDU 1702 STL
- HDU 1702 FIFO FILO
- hdu
- hdu
- HDU
- hdu ()
- hdu
- hdu
- HDU
- HDU
- hdu
- Piggy-Bank hdu 1114
- poj 2942——Knights of the Round Table
- Remote Debugging on Android
- 网上看到的Android面试题集合(精)
- struts.xml中package的namespace属性
- hdu 1702
- 今天去车厂开会,重点谈提高用户体验的问题
- 最小生成树--poj1758
- 从HttpServletRequest中获取域名
- hdu1671Phone List(字典树---判断有无相同的前缀单词)
- hdu 4650 Minimum Average Weight Path
- Android系统信息获取 之七:获取IP地址和MAC地址
- ifstream打开含中文路径文件时失败的问题
- 黑马程序员:毕向东java视频之多线程篇