Poj1028 Web Navigation 【简单模拟】

http://poj.org/problem?id=1028

题目大意:默认主页为“http://www.acm.org/”,输入为指令,输出为当前网站的网址。输入的指令有四种:

1VISIT 访问一个新的网站

2BACK 返回之前访问的网站

3FORWARD 前往后一个访问的网站

4QUIT 退出

直接开个数组记录一下,模拟就行

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
using namespace std;
template <class T> void checkmin(T &t,T x) {if(x < t) t = x;}
template <class T> void checkmax(T &t,T x) {if(x > t) t = x;}
template <class T> void _checkmin(T &t,T x) {if(t==-1) t = x; if(x < t) t = x;}
template <class T> void _checkmax(T &t,T x) {if(t==-1) t = x; if(x > t) t = x;}
typedef pair <int,int> PII;
typedef pair <double,double> PDD;
typedef long long ll;
#define foreach(it,v) for(__typeof((v).begin()) it = (v).begin(); it != (v).end ; it ++)
char s[1010][100] , od[100];
int cnt = 1 , pos = 1;
int main() {
    while(~scanf("%s",od)) {
        strcpy(s[1],"http://www.acm.org/");
        if(od[0] == 'Q') break;
        else if(od[0] == 'V') {
            pos ++; cnt = pos;
            scanf("%s",s[cnt]);
            printf("%s\n",s[cnt]);
        }
        else if(od[0] == 'B') {
            if(pos == 1) printf("Ignored\n");
            else printf("%s\n" , s[--pos]);
        }
        else if(od[0] == 'F') {
            if(pos == cnt) printf("Ignored\n");
            else printf("%s\n" , s[++pos]);
        }
    }
    return 0;
}

 

转载于:https://www.cnblogs.com/aiiYuu/archive/2013/04/05/3000713.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值