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 ibm at 2004-04-28 19:19:59 on Problem 1028
#include<stdio.h>
#include<string.h>
#define MAX1 100
#define MAX2 60
typedef struct 
{
	char save[MAX1][MAX2];
	int top;
}stack;


void main()
{
	stack *bk,*fw;
	char cur_str[MAX2]={"http://www.acm.org/"};
	char get_str[MAX2];
	char c,temp;
	int i,j,tag;
	bk->top=-1;
	fw->top=-1;
	while(1)
	{ 
	  j=0;
	  gets(get_str);
	  c=(int)get_str[0];
	  for(i=0;get_str[i]!=' ';i++);
      while(get_str[++i])
         get_str[j++]=get_str[i];
      get_str[j]='\0';
	  if(c!=81)
	  {switch(c)
	  {
	  case 86: strcpy(bk->save[++(bk->top)],cur_str);
		        strcpy(cur_str,get_str);
				printf("%s\n",cur_str);
                fw->top=-1;
				break;
	  case 66: if(bk->top!=-1)
				   {
					   strcpy(fw->save[++(fw->top)],cur_str);
		               strcpy(cur_str,bk->save[(bk->top)--]);
				       printf("%s\n",cur_str);
				   }
		           else  printf("Ignored\n");
			       break;
	  case 70: if(fw->top!=-1)
				   {
					   strcpy(bk->save[++(bk->top)],cur_str);
		               strcpy(cur_str,fw->save[(fw->top)--]);
				       printf("%s\n",cur_str);
				   }
		           else  printf("Ignored\n");
				   break;
	  
	  }
	  }
	  else {printf("Ignored\n");
	        break;}

	}
}
		        




		        

	





			


	   
	







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