main.cpp
来自「acm题解: Web Navigation 使用堆来解决」· C++ 代码 · 共 45 行
CPP
45 行
#include <iostream>#include <vector>#include <string>
using namespace std;
int main()
{ string current = "http://www.acm.org/"; vector<string> back_history(0); vector<string> forw_history(0);
string line; cin>>line; while(line!="QUIT"){ if(line == "VISIT"){ cin>>line; back_history.push_back(current); forw_history.clear(); current = line; cout<<current<<endl; }else if(line == "BACK"){ if(back_history.size()==0){ cout<<"Ignored"<<endl; }else{ line = back_history.back(); back_history.pop_back(); forw_history.push_back(current); current = line; cout<<current<<endl; } }else if(line == "FORWARD"){ if(forw_history.size()==0){ cout<<"Ignored"<<endl; }else{ line = forw_history.back(); forw_history.pop_back(); back_history.push_back(current); current = line; cout<<current<<endl; } } cin>>line; }
return 0;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?