1337.cpp

来自「这是哈尔滨工业大学acmOJ的源代码」· C++ 代码 · 共 39 行

CPP
39
字号
/*  This Code is Submitted by wywcgs for Problem 1337 on 2005-03-23 at 14:01:14 */ 
#include <stdio.h>
#include <string.h>

int main()
{
    char back[100][72], forward[100][72], current[72], command[10];
    int backP = 0, forP = 0;
    
    strcpy(current, "http://www.acm.org/");
    while(scanf("%s", command) == 1){
        if(!strcmp(command, "QUIT")){
            return 0;
        }else if(!strcmp(command, "FORWARD")){
            if(forP != 0){
                printf("%s\n", forward[--forP]);
                strcpy(back[backP++], current);
                strcpy(current, forward[forP]);
            }else{
                printf("Ignored\n");
            }
        }else if(!strcmp(command, "BACK")){
            if(backP != 0){
                printf("%s\n", back[--backP]);
                strcpy(forward[forP++], current);
                strcpy(current, back[backP]);
            }else{
                printf("Ignored\n");
            }
        }else if(!strcmp(command, "VISIT")){
            strcpy(back[backP++], current);
            scanf("%s", current);
            printf("%s\n", current);
            forP = 0;
        }
    }
    
    return 0;
}

⌨️ 快捷键说明

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