| ||||||||||
| 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 | |||||||||
Re:Notice~比较脑残的水题~~贡献幼稚代码~#include<iostream>
#include<fstream>
#include<string>
using namespace std;
int main()
{
//ifstream cin("a.txt");
string command;
string str[120];
int prv[120], next[120], k = 2, temp = 1;
memset(prv, 0, sizeof(prv));
memset(next, 0, sizeof(next));
str[1] = "http://www.acm.org/";
while (cin>>command)
{
if (command == "VISIT")
{
cin>>str[k];
cout<<str[k]<<endl;
next[temp] = k;
prv[k] = temp;
temp = k++;
}else if (command == "BACK")
{
if (!prv[temp])
{
printf("Ignored\n");
temp = 1;
}
else {
cout<<str[prv[temp]]<<endl;
temp = prv[temp];
}
}
else if (command == "FORWARD")
{
if (!next[temp])
printf("Ignored\n");
else {
cout<<str[next[temp]]<<endl;
temp = next[temp];
}
}
else 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