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 |
![ContractedBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![ExpandedBlockStart.gif](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
#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 ;
}
#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 按照题意倒腾吧 简单的很