zoj1061 Web Navigation

  1. //zoj1061 Web Navigation
  2. //Accepted 1061 C++ 00:00.03 852K
  3. #include <iostream>
  4. #include <string>
  5. #include <cstdio>
  6. using namespace std;
  7.  
  8. void solve()
  9. {
  10.        char t[10],s[101][71]={"http://www.acm.org/"};
  11.        int cnt=1,pos=0;
  12.        while (1){
  13.               cin >> t;
  14.               if (strcmp(t,"QUIT")==0) break;
  15.               if (strcmp(t,"VISIT")==0){
  16.                      pos++;
  17.                      cin >> s[pos];
  18.                      cout << s[pos] << endl;
  19.                      cnt = pos+1;
  20.               }
  21.               if (strcmp(t,"BACK")==0){
  22.                      pos--;
  23.                      if (pos<0) {
  24.                             pos = 0;
  25.                             cout << "Ignored" << endl;
  26.                      }
  27.                      else cout << s[pos] << endl;
  28.               }
  29.               if (strcmp(t,"FORWARD")==0){
  30.                      pos++;
  31.                      if (pos<cnt) cout << s[pos] << endl;
  32.                      else {
  33.                             pos = cnt-1;
  34.                             cout << "Ignored" << endl;
  35.                      }
  36.               }
  37.        }
  38. }
  39.  
  40. int main()
  41. {
  42. #ifdef ONLINE_JUDGE
  43. #else
  44.        freopen("1061.txt","r",stdin);
  45. #endif
  46.        int n;
  47.        while (cin >> n)
  48.               for (int i=0; i<n; ++i){
  49.                      if (i>0) cout << endl;
  50.                      solve();
  51.               }
  52. #ifdef ONLINE_JUDGE
  53. #else
  54.        fclose(stdin);
  55. #endif
  56.        return 0;
  57. } 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值