| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
一次AC代码//Dec 12 2009
#include<iostream>
#include<string>
using namespace std;
int main()
{
string command,URL,fstack[101],bstack[101],curent_page;
curent_page="http://www.acm.org/";
int bp=-1,fp=-1;
while(cin>>command)
{
if(command=="VISIT")
{
cin>>URL;
bstack[++bp]=curent_page;
curent_page=URL;
fp=-1;
cout<<curent_page<<endl;
}
else if(command=="BACK")
{
if(bp==-1)
cout<<"Ignored"<<endl;
else
{
fstack[++fp]=curent_page;
curent_page=bstack[bp--];
cout<<curent_page<<endl;
}
}
else if(command=="FORWARD")
{
if(fp==-1)
cout<<"Ignored"<<endl;
else
{
bstack[++bp]=curent_page;
curent_page=fstack[fp--];
cout<<curent_page<<endl;
}
}
else if(command=="QUIT")
break;
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator