#include<iostream> #include<cmath> #include<iomanip> #include<cstring> #include<string> #include<vector> #include<algorithm> using namespace std; int main() { vector<string>a; vector<string>b; string s2 = "http://www.acm.org/"; a.push_back(s2); string s; while (getline(cin, s)) { if (s == "QUIT") break; if (s[0] == 'V') { string s1 = s.substr(6,s.size()-6); cout << s1<<endl; a.push_back(s1); } else if (s == "BACK") { if (a.size() > 1) { b.push_back(a[a.size() - 1]); a.pop_back(); cout << a[a.size() - 1] << endl; } else cout << "Ignored" << endl; } else if (s == "FORWARD") { if (b.size() <=1) cout << "Ignored" << endl; else { cout << b[b.size() - 1] << endl; a.push_back(b[b.size() - 1]); b.pop_back(); } } } } |
Double click to view unformatted code.