您的位置:首页 > 其它

hdu Web Navigation (模拟,只需注意vist后,没有forward)

2012-07-11 15:53 387 查看
#include <stdio.h>
#include <string.h>

char web[10000][75];

int main(){
    char command[10];
    int i = 0,j;
    memset(web,'\0',sizeof(web));

    while(1){
        scanf("%s",command);
        if(command[0] == 'V'){
            i++;
            scanf("%s",web[i]);
            printf("%s\n",web[i]);
            for(j = i + 1;j < 10000;j++)
                web[j][0] = '\0';
        }
        else if(command[0] == 'B'){
            if(i == 0){
                printf("Ignored\n");
            }
            else if(i == 1){
                printf("http://www.acm.org/\n");
                i--;
            }
            else{
                i--;
                printf("%s\n",web[i]);
            }
        }
        else if(command[0] == 'F'){
            i++;
            if(web[i][0] != '\0'){
                printf("%s\n",web[i]);
            }
            else{
                printf("Ignored\n");
                i--;
            }
        }
        else{
            break;
        }
    }
    return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: