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

Re:可以用二维数组做,代码少点!

Posted by huangchang9001 at 2011-03-25 21:30:41 on Problem 1028
In Reply To:Re:双向链表就可以轻松实现,这题就是纯链表操作 Posted by:huangchang9001 at 2011-03-25 21:29:17
#include<stdio.h>
#include<string.h>
char w[101][71];
char s[10];
int c;
int ftop;
void main()
{
	c=0;
	ftop=0;
	strcpy(w[0],"http://www.acm.org/");
	while(scanf("%s",s)!=EOF&&strcmp(s,"QUIT")!=0)
	{
		if(strcmp(s,"VISIT")==0)
		{
			c++;
			scanf("%s",w[c]);
			printf("%s\n",w[c]);
			ftop=c;
		}
	    else if(strcmp(s,"BACK")==0)
		{
			if(c>0)
			{
				c--;
				printf("%s\n",w[c]);
			}
			else
				printf("Ignored\n");
		}
		else if(strcmp(s,"FORWARD")==0)
		{
			if(c<ftop)
			{
				c++;
				printf("%s\n",w[c]);
			}
			else
				printf("Ignored\n");
		}
		else
		{
			printf("wrong\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