POJ 1028:http://acm.pku.edu.cn/JudgeOnline/problem?id=1028
模拟浏览器前进、后退、访问到某个页面的过程。又是一道水题,我什么时候才能做到水王之王的位置?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | #include<iostream> #include<string> using namespace std; int main() { string cmd; string stack[101] = {"http://www.acm.org/"}; int B = 0, F = B; while(cin>>cmd) { switch(cmd[0]) { case 'Q': return 0; break; case 'V': cin>>stack[++B]; cout<<stack[B]<<endl; F = B; break; case 'B': if(--B < 0) { cout<<"Ignored"<<endl; B = 0; } else cout<<stack[B]<<endl; break; case 'F': if(++B > F) { cout<<"Ignored"<<endl; --B; } else cout<<stack[B]<<endl; break; default: break; } } return 0; } |
你好!除了代码,此处没有多少原创之物,皆为本人搜集、整理、总结之记录与心得,欢迎转载分享!转载时请尽量注明出处,将不胜感激。祝你健康、快乐!
水王之王一直是我远大的目标!