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 zzzzzz at 2004-12-16 17:56:14 on Problem 1028
第一个程序是回到初始网站重新计数;第二个是能将所有到过的网站都BACK出来;这两个都不能过.
第一个:

#include<stdio.h>
#include<string.h>
void main()
{
	char way[105][10],url[105][80],a[100],store[105][80],s[]="http://www.acm.org/";

	int i,j,w=1;
	strcpy(url[0],s);
	
	for(i=1;;i++)
	{
		scanf("%s",a);
		if(a[0]=='h')
		{
			strcpy(store[w-1],a);
			
		}
		if(a[0]=='V'||a[0]=='B'||a[0]=='F')
		{
			strcpy(way[w],a);
			w++;
		}
		if(a[0]=='Q')break;
	}
    
	w=w-1;
	
	
	int m=0,k=0;
	for(j=1;j<=w;j++)
	{
		if(way[j][0]=='F')
		{
			if(m+1<=k)
			{
				printf("%s\n",url[m+1]);
				m++;
			}
			else  printf("Ignored\n");
		}
        
		
		if(way[j][0]=='B')
		{
			if(m-1>=0)
			{
				printf("%s\n",url[m-1]);
				m--;
			}
			else  printf("Ignored\n");
		}
 
		if(way[j][0]=='V')
		{
			k=m+1;m++;
			strcpy(url[k],store[j]);
			printf("%s\n",url[m]);
			
		}
	}
}


第二个:
#include<stdio.h>
#include<string.h>
void main()
{
	char way[105][10],url[105][80],m[105],store[105][80];char begin[]="http://www.acm.org/";
	int i,j,w=1;
	strcpy(store[0],begin);
	 
	for(i=1;;i++)
	{
		scanf("%s",m);
		
		if(m[0]=='V')
		{
			strcpy(way[w],m);
			w++;
            scanf("%s",m);
            strcpy(url[w-1],m);

		}
		if(m[0]=='B'||m[0]=='F')
		{
			strcpy(way[w],m);
			w++;
		}
		if(m[0]=='Q')break;
	}
    
	w=w-1;
	
	
	int a=0,k=0,u=1;
	for(j=1;j<=w;j++)
	{
		 if(way[j][0]=='V')
		{
			 strcpy(store[u],url[j]);
			 
			 a=u;
			 k=u;
			 printf("%s\n",store[a]);
		     u++;
		 }	
		 
		 
		 if(way[j][0]=='F')
		{
			if(a+1<=k)
			{
				a++;
				printf("%s\n",store[a]);
				strcpy(store[u],store[a]);
		        u++;
			}
			else  printf("Ignored\n");
		}
        
		
		if(way[j][0]=='B')
		{
			if(a-1>=0)
			{
				a--;
				printf("%s\n",store[a]);
				strcpy(store[u],store[a]);
		        u++;
			}
			else  printf("Ignored\n");
		}
 
		
		
		
	}
}

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