forked from zhuli19901106/poj
-
Notifications
You must be signed in to change notification settings - Fork 0
/
POJ1028(AC).cpp
84 lines (79 loc) · 1.07 KB
/
POJ1028(AC).cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int main()
{
int top;
int available;
int i;
int j;
int t;
string a[105];
char cmd[1000];
char head[20];
char url[200];
string urlstr;
string headstr;
//ofstream cout("out.txt");
for(i = 0; i < 105; i++)
{
a[i] = "";
}
a[0] = "http://www.acm.org/";
available = 1;
top = 1;
while(1)
{
gets(cmd);
sscanf(cmd, "%s", head);
headstr = head;
if(headstr == "QUIT")
{
break;
}
else if(headstr == "BACK")
{
if(top <= 1)
{
cout<<"Ignored"<<endl;
}
else if(top > 1)
{
top--;
cout<<a[top - 1]<<endl;
}
}
else if(headstr == "FORWARD")
{
if(available > top)
{
cout<<a[top]<<endl;
top++;
}
else
{
cout<<"Ignored"<<endl;
}
}
else if(headstr == "VISIT")
{
strcpy(url, cmd + 6);
urlstr = url;
a[top] = url;
cout<<a[top]<<endl;
top++;
if(available < top)
{
available = top;
}
else if(available > top)
{
available = top;
}
}
}
return 0;
}