Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

求解救,老是错的

Posted by 1774549483 at 2013-04-17 17:48:17 on Problem 1028
#include<stdio.h>
#include<string.h>
int main()
{
	char y=0,n,x=0,str[101][101],str1[101][101],str2[101][101],z,j=0;
	strcpy(str[0],"VISIT");	strcpy(str[1],"http://www.acm.org/");
		strcpy(str2[0],"http://www.acm.org/");
	for(n=2;strcmp(str[n-1],"QUIT")!=0;n++)
	{scanf("%s",str[n]);}
	for(n=0;strcmp(str[n-1],"QUIT")!=0;n++)
	{
		if((strcmp(str[n],"QUIT")==0)||(strcmp(str[n],"VISIT")==0)||(strcmp(str[n],"BACK")==0)||(strcmp(str[n],"FORWARD")==0))
		{	strcpy(str1[x],str[n]);
		x++;}}
	x=0;
	for(n=1;strcmp(str[n-1],"QUIT")!=0;n++)
	{if((strcmp(str[n],"QUIT")!=0)&&(strcmp(str[n],"VISIT")!=0)&&(strcmp(str[n],"BACK")!=0)&&(strcmp(str[n],"FORWARD")!=0))
	{strcpy(str2[x],str[n]);
	x++;}}

	x=0;
		for(z=0,n=0;strcmp(str1[n],"QUIT")!=0;z++,n++)
	{
			if(strcmp(str1[n],"VISIT")==0){
				if(strcmp(str2[x],str[z+1])==0&&n>1)
				{x++;n++;z++;j=x-1;}
				else
				{	z++;strcpy(str2[x+1],str[z]);j=x+1;}
			}
		if((strcmp(str1[n],"BACK")==0))	
		{x--;}
		if((strcmp(str1[n],"FORWARD")==0)||((strcmp(str1[n],"VISIT")==0)&&n>0))
		{x++;}

		if(x<0)
	{	printf("Ignored\n");x=0;}
		else if(x>j)
	{	printf("Ignored\n");x=j;}
	else
	{
		if(n>0)printf("%s\n",str2[x]);
}}}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator