HDU 1072 Nightmare
来源:互联网 发布:ubuntu更新软件的命令 编辑:程序博客网 时间:2024/06/02 16:57
题目http://acm.hdu.edu.cn/showproblem.php?pid=1072
题目稍长,慢慢看,这题结合栈和队列,基础题
#include<stack>#include<queue>#include<cstring>#include<iostream>using namespace std;void que_solve(int m){queue<int>q;char str[10];int a;//while(!q.empty())q.pop();while(m--){cin>>str;if(str[0] == 'I'){cin>>a;q.push(a);}else{if(q.empty())cout<<"None"<<endl;else{cout<<q.front()<<endl;q.pop();}}}}void sta_solve(int m){int a;char str[10];stack<int>s;while(m--){cin>>str;if(str[0] == 'I'){cin>>a;s.push(a);}else{if(s.empty())cout<<"None"<<endl;else{cout<<s.top()<<endl;s.pop();}}}}int main() { int n; while(cin>>n) { while(n--) { int m; char str[100]; cin>>m>>str; if(!strcmp(str,"FIFO")) que_solve(m); else if(!strcmp(str,"FILO")) sta_solve(m); // else测试用 // cout<<"error"<<endl; } } return 0; }
0 0
- HDU 1072 Nightmare
- BFS hdu 1072 Nightmare
- HDU 1072 Nightmare BFS
- HDU 1072 Nightmare
- hdu 1072 Nightmare BFS
- hdu Nightmare 1072
- Hdu 1072 - Nightmare
- hdu 1072 Nightmare bfs
- HDU-1072:Nightmare
- hdu 1072 Nightmare
- HDU 1072 Nightmare
- HDU-1072-Nightmare
- hdu 1072 Nightmare
- HDU 1072 Nightmare
- Nightmare hdu 1072
- hdu 1072 Nightmare
- hdu 1072 Nightmare
- HDU 1072 Nightmare(搜索)
- 全方位阐述HDFS
- Android开源介绍-UI组件
- 什么用户的什么需求
- Android动画分析之3D翻转效果
- hdu 1258 Sum It Up(dfs)
- HDU 1072 Nightmare
- 在springMVC+mybatis+Ajax+JSON+jQuery easyui的项目中,自定义全局异常处理器
- javascript实现简单的走马灯
- oracle中的raw类型
- load data file使用详解
- C++ primer(第五版) 练习 3.30 个人 见解
- Linux下如何将数据库脚本文件从sh格式变为sql格式
- Android应用如何实现换肤功能
- 【原创】《Linux设备驱动程序》学习之循序渐进 --- 与硬件通信