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

很简单的code 为什么会WA呢 求高人

Posted by thisishzr at 2011-05-16 22:32:43 on Problem 1028
#include<iostream>
#include<string>
using namespace std;
struct Stack
{
	string str[200];
	int top;
};
void Push(Stack *&s,string str1)
{
	s->top++;
	s->str[s->top]=str1;
}
void Pop(Stack *&s,string &str1)
{
	str1=s->str[s->top];
	s->top--;
}
int main()
{
	const string HP="http://www.acm.org/";
	string cmd;
	string cstr=HP;
	Stack *sb=new Stack();sb->top=-1;
	Stack *sf=new Stack();sf->top=-1;
	while(cin>>cmd)
	{
		if(cmd=="QUIT") break;
		if(cmd=="BACK")
		{
			if(cstr!=HP)Push(sf,cstr);
			if(sb->top==-1) cout<<"Ignored"<<endl;
			else
			{
				Pop(sb,cstr);
				cout<<cstr<<endl;
			}
		}
		if(cmd=="FORWARD")
		{
			Push(sb,cstr);
			if(sf->top==-1) cout<<"Ignored"<<endl;
			else{Pop(sf,cstr);cout<<cstr<<endl;}
		}
		if(cmd=="VISIT")
		{
			Push(sb,cstr);
			cin>>cstr;
			cout<<cstr<<endl;
			sf->top=-1;
		}

	}
//	system("pause");
	return 0;
}

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