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 |
找不到问题总是WA,求大侠帮助小弟不成熟的代码#include <stdio.h> #include <malloc.h> #include <string.h> #include <math.h> #include <stdlib.h> struct browser { char web[5000]; struct browser *p; }; typedef struct browser BROWSER; typedef BROWSER *BMW; BMW forward=NULL; BMW backward=NULL; void push(char a,char *p) { BMW newnode; newnode=(BMW)malloc(sizeof(BROWSER)); strcpy(newnode->web,p); if(a=='F') { newnode->p=forward ; forward=newnode; } else { newnode->p=backward; backward=newnode; } } char *pop(char a) { BMW top; char *q; if(a=='F') { if(forward!=NULL) { top=forward; forward=forward->p; q=top->web; return q; } else return(NULL); } else { if(backward!=NULL) { top=backward; backward=backward->p; q=top->web; return q; } else return(NULL); } } void qingkong() { forward=NULL; } void main() { char web[5000],t=0,acm[]="http://www.acm.org/\0",web2[5000],web3[5000]; char *p; p=&acm[0]; while(1) { gets(web); if(strcmp(web,"QUIT")==0) break; if(strcmp(web,"BACK")==0) { p=pop('B'); if(p!=NULL) { puts(p); push('F',web3); strcpy(web3,p); } else printf("Ignored\n"); } if(strcmp(web,"FORWARD")==0) { if(t!=0) push('B',web3); p=pop('F'); if(p!=NULL){ puts(p); strcpy(web3,p); } else printf("Ignored\n"); } if(web[0]=='V') { push('B',p); strcpy(web2,web); p=&web2[6]; strcpy(web3,p); puts(p); qingkong(); t++; } } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator