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

Re:Notice~比较脑残的水题~~贡献幼稚代码~

Posted by like680623 at 2011-02-05 12:40:19 on Problem 1028
#include<iostream>
#include<fstream>
#include<string>
using namespace std;

int main()
{
	//ifstream cin("a.txt");
	string command;
	string str[120];
	int prv[120], next[120], k = 2, temp = 1;
	memset(prv, 0, sizeof(prv));
	memset(next, 0, sizeof(next));
	str[1] = "http://www.acm.org/";
	while (cin>>command)
	{
		if (command == "VISIT")
		{
			cin>>str[k];
			cout<<str[k]<<endl;
			next[temp] = k;
			prv[k] = temp;
			temp = k++;
		}else if (command == "BACK")
		{
			if (!prv[temp])
			{
				printf("Ignored\n");
				temp = 1;
			}
			else {
				cout<<str[prv[temp]]<<endl;
			    temp = prv[temp];
			}
		}
		else if (command == "FORWARD")
		{
			if (!next[temp])
				printf("Ignored\n");
			else {
				cout<<str[next[temp]]<<endl;
				temp = next[temp];
			}
		}
		else 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