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 |
Re:我的程序输出结果和题目一样,错在哪??In Reply To:我的程序输出结果和题目一样,错在哪?? Posted by:dexter at 2004-02-26 13:16:22 我刚才帮你调过了。你没看清题。每个堆栈最大值为100。数组和j改为200就行. > #include<stdio.h> > #include<string.h> > char str[100][70]; > static char cmd[7];//command > static char url[70];//web page > main() > { > int i,j; > char cur[70];//current page > i=-1;//-1 表示back栈空,100表示forward栈空 > j=100; > strcpy(cur,"http://www.acm.org"); > scanf("%s",cmd); > while(strcmp("QUIT",cmd)) > { > if(!strcmp(cmd,"VISIT")) > { > scanf("%s",url); > i++; > strcpy(str[i],cur); > strcpy(cur,url); > puts(cur); > j=100; > } > if(!strcmp(cmd,"BACK")) > { > if(i!=-1) > { > j--; > strcpy(str[j],cur); > strcpy(cur,str[i]); > i--; > puts(cur); > } > else > puts("Ignored"); > } > if(!strcmp(cmd,"FORWARD")) > { > if(j!=100) > { > i++; > strcpy(str[i],cur); > strcpy(cur,str[j]); > j++; > puts(cur); > } > else > puts("Ignored"); > } > scanf("%s",cmd); > } > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator