HDU 1702 ACboy needs your help again!
2012-07-27 14:05
405 查看
http://acm.hdu.edu.cn/showproblem.php?pid=1702
G++交,基本stl栈和队列操作
View Code
G++交,基本stl栈和队列操作
View Code
#include <iostream> #include <stack> #include <queue> using namespace std ; int main() { int t ; scanf("%d",&t) ; while(t--) { int n,m ; string str ; cin >> n >> str ; if(str=="FIFO") { queue <int> q ; while(n--) { cin >> str ; if(str=="IN") { cin >> m ; q.push(m) ; } else { if(q.empty()) puts("None") ; else { printf("%d\n",q.front()) ; q.pop() ; } } } if(!q.empty()) q.pop() ; } else { stack <int> s ; while(n--) { cin >> str ; if(str=="IN") { cin >> m ; s.push(m) ; } else { if(s.empty()) puts("None") ; else { printf("%d\n",s.top()) ; s.pop() ; } } } if(!s.empty()) s.pop() ; } } return 0 ; }
相关文章推荐
- hdu 1702 ACboy needs your help again!
- HDU1702--ACboy needs your help again!(栈和队列)
- hdu 1702 ACboy needs your help again!
- HDU - 1702 - ACboy needs your help again!(栈&&队列)
- HDU-1702-ACboy needs your help again!
- hdu 1702 ACboy needs your help again!
- HDU1702 acm 数据结构 ACboy needs your help again!
- HDU 1702 ACboy needs your help again!
- 【HDU】1702---ACboy needs your help again!(栈&&队列)
- HDU-1702 ACboy needs your help again!【栈与队列】
- hdu 1702 ACboy needs your help again!
- 【STL基础01】HDU-1702-ACboy needs your help again!
- HDU 1702----ACboy needs your help again!(栈和队列)
- Hdu 1702 ACboy needs your help again!
- HDU 1702 ACboy needs your help again! (模拟栈和队列)
- HDU:1702 ACboy needs your help again!(简单栈、队列)
- HDU 1702 ACboy needs your help again!
- ACboy needs your help again! HDU - 1702
- HDU 1702 - ACboy needs your help again!
- HDU 1702 ACboy needs your help again!(栈和队列)