#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; }
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)