1828115_ac_15ms_212k.c

来自「北大大牛代码 1240道题的原代码 超级权威」· C语言 代码 · 共 42 行

C
42
字号
# include <stdio.h>
# include <string.h>

void main()
{
 int i, j, mark;
 char url[80], current[80], act[20], ba[1000][100], fw[1000][100];
 
 strcpy(current,"http://www.acm.org/");
 i = j = 0;
 while(1)
 { 
   mark = 0;
   scanf("%s",act);
   if(strcmp(act,"QUIT") == 0)  break;
   if(strcmp(act,"VISIT") == 0) 
   {
    scanf("%s",url);
    
    strcpy(ba[++i],current);
    strcpy(current,url);
    j = 0;
   }
   if(strcmp(act,"BACK") == 0)
   {
    if(i > 0)
    {strcpy(fw[++j],current);strcpy(current,ba[i--]);}
    else mark = 1;
   }
   if(strcmp(act,"FORWARD") == 0)
   {
     if(j <= 0)
     mark = 1;
     else 
     {strcpy(ba[++i],current);strcpy(current,fw[j--]);}
   }
   if(mark) printf("Ignored\n");
   else puts(current);
 }
 
 
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?