标签:9.png using visit UI span clu stack 分析 std
分析:题目中说用栈实现,我觉得这样很麻烦,就用了一个数组+指针解决了.其实就是大模拟.
#include <stack> #include <string> #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; string s, ss; stack <string> s1, s2; string q[1010]; int cnt = 1, maxx = 1; int main() { q[1] = "http://www.acm.org/"; while (cin >> s && s != "QUIT") { if (s == "VISIT") { cin >> ss; q[++cnt] = ss; maxx = cnt; cout << ss << endl; } else if (s == "BACK") { if (cnt - 1 <= 0) printf("Ignored\n"); else { cnt--; cout << q[cnt] << endl; } } else { if (cnt + 1 > maxx) printf("Ignored\n"); else { cnt++; cout << q[cnt] << endl; } } } return 0; }
标签:9.png using visit UI span clu stack 分析 std
原文地址:http://www.cnblogs.com/zbtrs/p/7710466.html