zoj 1061 Web Navigation

zoj 1061 Web Navigation,第1张

zoj 1061 Web Navigation
#include <stack>#include <string>#include <iostream>using namespace std;int main(){    int n;     cin >> n;    while(n--)     {        string command, url, curURL = "http://www.acm.org/";        stack<string> backward, forward;        while(1)        {  cin >> command;  if(command == "QUIT")      break;  if(command == "VISIT") {      backward.push(curURL);      cin >> curURL;      while(forward.empty() == false)          forward.pop();  }  if(command == "BACK")  {      if(backward.empty())      {          cout << "Ignored" << endl;         continue;      }      else      {          forward.push(curURL);          curURL = backward.top();          backward.pop();      }  }  if(command == "FORWARD") {      if(forward.empty())      {          cout << "Ignored" << endl;          continue;      }      else      {          backward.push(curURL);          curURL = forward.top();          forward.pop();      }  }  cout << curURL << endl;         }         if(n)  cout << endl;     }     return 0; }

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/4911841.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-12
下一篇 2022-11-12

发表评论

登录后才能评论

评论列表(0条)

保存