Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
纪念一下~~~~~~~话说c++的引用参数好给力啊#include <stdio.h> #include <string.h> #define maxn 110 typedef struct { char page[75]; }element; void pop(int& top,element *stack) { printf("%s\n",stack[top].page); (top)--; } void push(char *c,element *stack,int& top) { strcpy(stack[++(top)].page,c); } int main() { element stack_f[maxn],stack_b[maxn]; int top,top1; char CurrentPage[75]; char homepage[]={"http://www.acm.org/"}; char s[75]; strcpy(CurrentPage,homepage); element t; top=top1=-1; while(~scanf("%s",s)) { if(!strcmp(s,"VISIT")) { scanf("%s",t.page); printf("%s\n",t.page); push(CurrentPage,stack_b,top1); strcpy(CurrentPage,t.page); top=-1; } else if(!strcmp(s,"BACK")) { if(top1==-1) {printf("Ignored\n"); continue ;} push(CurrentPage,stack_f,top); strcpy(CurrentPage,stack_b[top1].page); pop(top1,stack_b); } else if(!strcmp(s,"FORWARD")) { if(top==-1) {printf("Ignored\n"); continue ;} push(CurrentPage,stack_b,top1); strcpy(CurrentPage,stack_f[top].page); pop(top,stack_f); } else if(!strcmp(s,"QUIT")) break; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator