ZOJ1061
来源:互联网 发布:html怎么调用php文件 编辑:程序博客网 时间:2024/05/18 20:35
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=61
用容器stack,剩下的就是模拟了。
#include<iostream>#include<stack>#include<string>using namespace std;stack<string> Front; //前进栈stack<string> Back; //后退栈string URL; //当前页void BACK(string order){ if (Back.empty()) { cout<<"Ignored"<<endl; return; } order = order.erase(0,4); Front.push(URL); URL = Back.top(); Back.pop(); cout<<URL<<endl;}void FORWARD(string order){ if (Front.empty()) { cout<<"Ignored"<<endl; return; } order = order.erase(0,7); Back.push(URL); URL = Front.top(); Front.pop(); cout<<URL<<endl;}void VISIT(string order){ order = order.erase(0,6); Back.push(URL); URL = order; cout<<URL<<endl; while (!Front.empty()) Front.pop();}int main(){ int N; cin>>N; while (N--) { string order; bool Exit = false; URL = "http://www.acm.org/"; while (getline(cin,order) && order!="QUIT") { switch (order[0]) { case 'B':BACK(order);break; case 'F':FORWARD(order);break; case 'V':VISIT(order);break; } } while (!Front.empty()) Front.pop(); while (!Back.empty()) Back.pop(); if (N) { cin.ignore(); cout<<endl; } } return 0;}
0 0
- ZOJ1061
- zoj1061
- zoj1061 Web Navigation
- ZOJ1061 Web Navigation
- UVALive2356 ZOJ1061 Web Navigation【堆栈+模拟】
- zoj1061 Web Navigation (栈——基础练习)
- Android开发学习之路--UI之自定义布局和控件
- 志不强者智不达
- uva 11538 组合
- Android Annotations环境搭建(Android Studio)
- Aireplay-ng的6种攻击模式详解
- ZOJ1061
- Self Summary: Basic concepts of GPU
- xsl-fo图文混排的问题解决
- uva 11401 荣斥
- 1007. Maximum Subsequence Sum (25)
- Android笔记activity的生命周期
- hdoj 2050 折线分割平面
- HTML5 Canvas学习笔记之详解弧线的绘制
- 1.UI