| Run ID | User | Problem | Result | Memory | Time | Language | Code Length | Submit Time |
| 6630198 | kingpro | 1028 | Accepted | 216K | 16MS | C++ | 708B | 2010-03-25 22:32:36 |
PKU 1028 Web Navigation
#include <iostream>
#include <stack>
using namespace std;
int main()
{
stack<char *> forward, back;
char * current="http://www.acm.org/";
char command[8];
while(cin>>command)
{
if(command[0]=='Q') break;
switch(command[0])
{
case 'B':
cout<<(back.empty() ? "Ignored" : (forward.push(current), current=back.top(), back.pop(), current))<<endl;
break;
case 'F':
cout<<(forward.empty() ? "Ignored" : (back.push(current), current=forward.top(), forward.pop(), current))<<endl;
break;
case 'V':
back.push(current), current=new char[71], cin>>current;
while(!forward.empty()) forward.pop();
cout<<current<<endl;
break;
}
}
return 0;
}
两个stack 按照题意倒腾吧 简单的很
Author: CriusWuBlog: http://kingpro.cnblogs.comContact: kingpro@live.cn
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.

posted on
浙公网安备 33010602011771号