标签:
1 #include <stdio.h> 2 #include <string.h> 3 4 const int MAX = 128; 5 6 struct URL{ 7 char a[MAX][MAX]; 8 int dir, max; 9 10 void create(){dir = 0; max = 0; memset(a, 0, sizeof(a)); strcpy(a[0], "http://www.acm.org/");} 11 bool back(){if(dir > 0) {dir--; return true;} return false;} 12 bool fwd() {if(dir < max) {dir++; return true;} return false;} 13 void viw(char * str) {strcpy(a[++dir], str); max = dir;} 14 void show(){printf("%s\n", a[dir]);} 15 }; 16 17 URL url; 18 19 int main() 20 { 21 #ifdef CDZSC_OFFLINE 22 freopen("in.txt", "r", stdin); 23 freopen("out.txt", "w", stdout); 24 #endif 25 char str[MAX]; 26 url.create(); 27 while(~scanf("%s", str)) 28 { 29 switch(str[0]) 30 { 31 case ‘V‘: scanf("%s", str); url.viw(str); url.show(); break; 32 case ‘F‘: if(url.fwd()) url.show(); else printf("Ignored\n"); break; 33 case ‘B‘: if(url.back()) url.show(); else printf("Ignored\n"); break; 34 case ‘Q‘: url.create(); break; 35 } 36 } 37 return 0; 38 }
标签:
原文地址:http://www.cnblogs.com/LiuACG/p/4251032.html