poj 1028 Web Navigation
2013-07-28 20:02
357 查看
链接:点击打开链接
对栈的运用。
对栈的运用。
#include<iostream> #include<stack> #include<string> #include<cstdio> #include<cstring> using namespace std; int main(){ stack<string>forward,backward; int i,j; string s,current="http://www.acm.org/"; while(getline(cin,s)){ if(s=="QUIT") break; if(s.size()>7){ backward.push(current); current=s.substr(6); cout<<current<<endl; while(!forward.empty()) forward.pop(); } else if(s=="BACK"){ if(backward.empty()) cout<<"Ignored"<<endl; else{ forward.push(current); current=backward.top(); backward.pop(); cout<<current<<endl; } } else if(s=="FORWARD"){ if(forward.empty()) cout<<"Ignored"<<endl; else{ backward.push(current); current=forward.top(); forward.pop(); cout<<current<<endl; } } } return 0; }
相关文章推荐
- poj-1028 Web Navigation
- POJ-1028-Web Navigation
- poj 1028 Web Navigation
- POJ 1028----Web Navigation
- Web Navigation - POJ 1028 栈
- POJ1028 Web Navigation
- POJ 1028-Web Navigation
- poj_1028 Web Navigation
- poj1028 Web Navigation
- POJ 1028 Web Navigation 笔记
- POJ 1028: Web Navigation
- POJ-1028 Web Navigation(STL)
- 模拟->YY POJ 1028 Web Navigation
- poj 1028 Web Navigation(模拟)
- POJ 1028 - Web Navigation
- poj算法题1028——Web Navigation
- POJ 1028:Web Navigation
- poj 1028 Web Navigation
- POJ 1028 / East Central North America 2001 Web Navigation (栈)
- POJ-1028-Web Navigation