#include <stdio.h>
#include <string.h>
main()
{
char str[110][100]={"http://www.acm.org/"};
char command[100]={0};
int top=0,rear=0;
while (scanf("%s", command),strcmp(command, "QUIT")) {
if (!strcmp(command, "BACK")){
if (rear > 0){
rear--;
printf("%s\n", str[rear]);
}
else
printf("Ignored\n");
}
else if (!strcmp(command, "FORWARD")) {
if (rear < top) {
rear++;
printf("%s\n", str[rear]);
}
else
printf("Ignored\n");
}
else if (!strspn(command, "VISIT ")) {
top = ++rear;
strcpy(str[rear], &command[strspn(command, "VISIT ")]);
printf("%s\n", str[rear]);
}
}
}
POJ-1028
最新推荐文章于 2022-12-21 21:07:25 发布