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 TSERROF at 2012-09-02 12:06:49 on Problem 1028
我就完全按照题意写了一个,什么也没看,就ac了,等会再看看原理
#include <iostream>
#include <string>
#include<algorithm>
#include <stack>
using namespace std;
stack<string>backwards;
stack<string>forwards;
int main()
{
	string text;
	string current="http://www.acm.org/";
	while(getline(cin,text))
	{
		if(text=="QUIT")break;
		else if(text=="BACK")
		{		
			if(backwards.empty())cout<<"Ignored"<<endl;			
			else 
			{
				forwards.push(current);
				current=backwards.top();
				backwards.pop();
				cout<<current<<endl;		
			}
		}
		else if(text=="FORWARD")
		{			
			if(forwards.empty())cout<<"Ignored"<<endl;
			else
			{
				backwards.push(current);
				current=forwards.top();
				forwards.pop();
				cout<<current<<endl;
			}
		}
		else
		{
			while(!forwards.empty())forwards.pop();
			backwards.push(current);
			current=text.substr(6);			
			cout<<current<<endl;
		}				
	}
	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