-
Notifications
You must be signed in to change notification settings - Fork 0
/
1113 - Discover the Web.c
executable file
·62 lines (60 loc) · 1.34 KB
/
1113 - Discover the Web.c
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
#include<stdio.h>
#include<string.h>
int main()
{
int x,t;
scanf("%d",&x);
for(t=1;t<=x;t++)
{
printf("Case %d:\n",t);
char str[1000][100],command[100];
strcpy(str[0],"http://www.lightoj.com/");
int n,p;
n=0;
p=0;
while(1)
{
scanf("%s",command);
getchar();
if(!strcmp(command,"QUIT"))
{
break;
}
else if(!strcmp(command,"VISIT"))
{
n++;
p=n;
scanf("%s",str[n]);
getchar();
printf("%s\n",str[n]);
}
else if(!strcmp(command,"BACK"))
{
n--;
if(n<0)
{
printf("Ignored\n");
n++;
}
else
{
printf("%s\n",str[n]);
}
}
else if(!strcmp(command,"FORWARD"))
{
n++;
if(n>p)
{
printf("Ignored\n");
n--;
}
else
{
printf("%s\n",str[n]);
}
}
}
}
return 0;
}