比较简单的一个模拟题,根据实际浏览器的操作来做
代码:
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
const int maxn=101;
char str[maxn][maxn];
int main()
{
strcpy(str[0],"http://www.acm.org/");
int cnt=0,now=0;
char op[20];
while(scanf("%s",op)!=EOF)
{
if(!strcmp(op,"QUIT"))
break;
if(!strcmp(op,"VISIT"))
{
cnt=now;
scanf("%s",str[++cnt]);
now=cnt;
printf("%s\n",str[now]);
}
else if(!strcmp(op,"BACK"))
{
now--;
if(now<0)
{
printf("Ignored\n");
now=0;
}
else
printf("%s\n",str[now]);
}
else
{
now++;
if(now>cnt)
{
printf("Ignored\n");
now=cnt;
}
else
printf("%s\n",str[now]);
}
}
return 0;
}