poj1028

很水,直接上代码吧。 

1 #include<iostream>
2 #include<string>
3 #include<vector>
4
5  using namespace std;
6
7
8
9 int main()
10 {
11 string now = "http://www.acm.org/";
12
13 vector<string> back;
14 vector<string> forward;
15
16 string tmp;
17
18 while(1)
19 {
20 cin>>tmp;
21 if(tmp == string("QUIT"))
22 {
23 break;
24 }
25 if(tmp[0]=='V')
26 {
27 string url;
28 cin>>url;
29 back.push_back(now);
30 forward.clear();
31 now=url;
32 cout<<now<<endl;
33 }
34 else if(tmp[0]=='B')
35 {
36 if(!back.empty())
37 {
38 forward.push_back(now);
39 now = back.back();
40 cout<<now<<endl;
41 back.pop_back();
42 }
43 else
44 {
45 cout<<"Ignored"<<endl;
46 }
47 }
48 else
49 {
50 if(!forward.empty())
51 {
52 back.push_back(now);
53 now = forward.back();
54 cout<<now<<endl;
55 forward.pop_back();
56 }
57 else
58 {
59 cout<<"Ignored"<<endl;
60 }
61 }
62 }
63 return 0;
64 }
65
66
67

 

posted on 2010-10-23 20:43  Weifeng Wang  阅读(246)  评论(0编辑  收藏  举报

导航