s:array[1..10000] of string;
i:integer;
st:string;
begin
s[1]:=’http://www.acm.org/’;
i:=1;
repeat
readln(st);
if st[1]=’V’ then begin inc(i);s[i]:=copy(st,7,length(st));writeln(s[i]);end;
if st[1]=’B’ then
if i<>1 then begin dec(i);writeln(s[i]);end else writeln(’Ignored’);
if st[1]=’F’ then
if s[i+1]=’’ then writeln(’Ignored’) else
begin inc(i);writeln(s[i]);end;
until st[1]=’Q’;
end.
测试结果错误.错误结果为:http://acm.ashland.edu/
http://asm.baylor.edu/acmipc/
http://acm.ashland.edu/
http://www.acm.org/
http://www.funtime.com/jokes
http://asm.baylor.edu/acmipc/
http://www.ibm.com/
http://asm.baylor.edu/acmipc/
http://www.ibm.com/
http://asm.baylor.edu/acmipc/
ftp://goodstuff.mysite.com/more/more/more/theend.html
Ignored
http://asm.baylor.edu/acmipc/
http://www.funtime.com/jokes
正确结果应为:http://acm.ashland.edu/
http://asm.baylor.edu/acmipc/
http://acm.ashland.edu/
http://www.acm.org/
http://www.funtime.com/jokes
Ignored
http://www.ibm.com/
http://www.funtime.com/jokes
http://www.ibm.com/
http://www.funtime.com/jokes
ftp://goodstuff.mysite.com/more/more/more/theend.html
Ignored
http://www.funtime.com/jokes
http://www.acm.org/
#include <string>
using namespace std;
string a[10000],t;
long i,n;
int main()
{//Coding by RenQing
i=1;n=i;
a[1]="http://www.acm.org/";
while (1)
{
getline(cin,t);
if (t=="QUIT") return 0;
if (t=="BACK")
{
if (i-1>0) cout<<a[--i]<<endl;
else cout<<"Ignored"<<endl;
continue;
}
if (t=="FORWARD")
{
if (i+1<=n) cout<<a[++i]<<endl;
else cout<<"Ignored"<<endl;
continue;
}
long j;i++;n=i;a[i]="";
for (j=6;j<=t.size()-1;j++)
{
a[i]=a[i]+t[j];
}
cout<<a[i]<<endl;
}
}