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 201101050424 at 2011-12-23 17:33:53 on Problem 1028
#include <stdio.h>
#include <string.h>
int main()
{
	char back[1001][1001];
	char forward[1001][1001];
	char command[1000];
	char address[1000];
	char cur[100];
	int i;
	int top1=-1;
	int top2=-1;
	int len;
    	strcpy(cur,"http://www.acm.org/");
	scanf("%s",command);
	getchar();
	while(1)
	{
		int flag1=0,flag2=0;
		if(command[0]=='V')
		{
			gets(address);
			top2++;
			for(i=0;i<strlen(cur);i++)
			{
				back[top2][i]=cur[i];
			}
			back[top2][i]='\0';
			for(i=0;i<strlen(address);i++)
			{
				cur[i]=address[i];
			}
			cur[i]='\0';
			top1=-1;
		}
		else if(command[0]=='B')
		{
			if(top2==-1)
			{
				flag1=1;
			}
			else
			{
			top1++;
			for(i=0;i<strlen(cur);i++)
			{
				forward[top1][i]=cur[i];
			}
			forward[top1][i]='\0';			
			//if(top2!=-1)
			{
				for(i=0;i<strlen(back[top2]);i++)
				{
					cur[i]=back[top2][i];
				}
				cur[i]='\0';	
				top2--;
			}
			}			

		}
		else if(command[0]=='F')
		{
			if(top1==-1)
			{
				flag2=1;
			}
			else
			{
			top2++;
			for(i=0;i<strlen(cur);i++)
			{
				back[top2][i]=cur[i];
			}
			back[top2][i]='\0';	
			//if(top1!=-1)
			{
				for(i=0;i<strlen(forward[top1]);i++)
				{
					cur[i]=forward[top1][i];
				}
				cur[i]='\0';
				top1--;	
			}
			}

		}
		else
		{
			break;
		}
		if(flag1==1||flag2==1)
		{
			printf("Ignored\n");
		}
		else
		{
			puts(cur);
		}
		scanf("%s",command);
		getchar();
	}
}

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