#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)  编辑 收藏 引用 所属分类: 未分类

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理