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

1028 1028 高手帮帮我哈 ~~~~~~~~~~

Posted by wyqt at 2006-04-10 15:42:17
#include<iostream.h>
#include<string.h>
#define N  100
typedef  struct T
{
	char URL[N][70];
	int top;
}Stack;
void InitStack(Stack &S)
{
	S.top=-1;
}
int StackEmpty(Stack S)
{
	if(S.top==-1)  return  1;
	else  return  0;
}
void push(Stack &S,char  str[70])
{
	S.top++;
	strcpy(S.URL[S.top],str);
}

void pop(Stack &S,char str[70])
{    
	strcpy(str,S.URL[S.top]);
	S.top--;
}
int main()
{
	Stack  forward,backward;
	char current[70]="http://www.acm.org/";
	char cmd[10];
	char InURL[70];
	int Emptymark;
	InitStack(forward);
	InitStack(backward);
	while(1)
	{
		cin>>cmd;
		if(strcmp(cmd,"QUIT")==0)
			break;
		else if(strcmp(cmd,"VISIT")==0)
		{   
			cin>>InURL;	     
			push(backward,current);
			strcpy(current,InURL);   
			InitStack(forward);
	     	 cout<<current<<endl;
		}
		else if(strcmp(cmd,"BACK")==0)
		{
		 Emptymark=StackEmpty(backward);
		 if(Emptymark==1) 
			cout<<"Ignored"<<endl;
		 else
		 {   push(forward,current);
			 pop(backward,current);
		     cout<<current<<endl;
		 }
		}
		else if(strcmp(cmd,"FORWARD")==0)
		{
			push(backward,current);
			 Emptymark=StackEmpty(forward);
		 if(Emptymark==1) 
			cout<<"Ignored"<<endl;
		 else
		 {
			 pop(forward,current);
			cout<<current<<endl;
		 }
		}
		else  continue;
	}
	return  0;
}
那位高手帮我看一下啊
怎么总是WA啊
郁闷了啊

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