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

没那回事,我用的stl ,0ms

Posted by lynxpengpeng at 2007-10-11 16:42:49 on Problem 1028
#include <string>
#include <iostream>
#include <vector>
#include <list>
#include <vector>
#include <algorithm>
#include <iostream>
#include <map>
#include <stack>
using namespace std;
int main()
{	
	stack<string> back;
	stack<string> forward;
	string tempt = "http://www.acm.org/";
	string in;
	while(cin>>in)
	{
		if(in == "QUIT")
			break;
		if(in[0] == 'V')
		{
			cin>>in;
			back.push(tempt);
			tempt = in;
			cout<<tempt<<endl;
			while(forward.size() != 0)
			{
				forward.pop();
			}
		}
		if( "BACK" == in)
		{
			if(back.size() == 0)
			{
				cout<<"Ignored"<<endl;
			}
			else
			{
				forward.push(tempt);
				tempt = back.top();
				cout<<tempt<<endl;
				back.pop();
			}
		}
		if(in == "FORWARD")
		{
			if(forward.size() == 0)
			{
				cout<<"Ignored"<<endl;
			}
			else
			{
				back.push(tempt);
				tempt = forward.top();
				forward.pop();
				cout<<tempt<<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