#include
<
stdio.h
>
#include
<
string
.h
>
#define
N 110
char
str[
10
];
char
queue[N][
100
];
int
top
=
0
;
int
len
=
1
;
int
main()
{
strcpy( queue[
++
top],
"
http://www.acm.org/
"
);
while
( scanf(
"
%s
"
, str), strcmp( str,
"
QUIT
"
)
!=
0
)
{
if
( strcmp( str,
"
VISIT
"
)
==
0
)
{
scanf(
"
%s
"
, queue[
++
top] );
printf(
"
%s\n
"
, queue[top] );
len
=
top;
}
else
if
( strcmp( str,
"
BACK
"
)
==
0
)
{
top
--
;
if
( top
<
1
)
{
printf(
"
Ignored\n
"
);
top
++
;
}
else
printf(
"
%s\n
"
, queue[top] );
}
else
if
( strcmp( str,
"
FORWARD
"
)
==
0
)
{
top
++
;
if
( top
>
len )
{ printf(
"
Ignored\n
"
); top
--
; }
else
printf(
"
%s\n
"
, queue[top] );
}
}
return
0
;
}
posted on 2008-10-30 13:16
Darren 阅读(334)
评论(0) 编辑 收藏 引用 所属分类:
未分类