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

一次AC代码

Posted by Algor at 2009-12-12 12:35:17 on Problem 1028
//Dec 12 2009
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string command,URL,fstack[101],bstack[101],curent_page;
	curent_page="http://www.acm.org/";
	int bp=-1,fp=-1;
	while(cin>>command)
	{
		if(command=="VISIT")
		{
			cin>>URL;
			bstack[++bp]=curent_page;
			curent_page=URL;
			fp=-1;
			cout<<curent_page<<endl;
		}
		else if(command=="BACK")
		{
			if(bp==-1)
				cout<<"Ignored"<<endl;
			else 
			{
				fstack[++fp]=curent_page;
				curent_page=bstack[bp--];
				cout<<curent_page<<endl;
			}
		}
		else if(command=="FORWARD")
		{
			if(fp==-1)
				cout<<"Ignored"<<endl;
			else
			{
				bstack[++bp]=curent_page;
				curent_page=fstack[fp--];
				cout<<curent_page<<endl;
			}
		}
		else  if(command=="QUIT")
			break;
	}
	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