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 handle2 at 2009-08-05 12:38:21 on Problem 1028
#include"iostream"
#include"string"
using namespace std;
struct Web{
	string s;
	int back;
	int ford;
}w[105];
string c;
int main()
{
	int i,j,order;
	w[0].s="http://www.acm.org/";
	w[0].back=-1;
	w[0].ford=-1;
	i=0;j=0;order=0;
	while(cin>>c)
	{
		if(c[0]=='Q')break;
		else if(c[0]=='V')
		{
			i++;
			cin>>w[i].s;
			w[i].back=order;
			w[i].ford=-1;
			cout<<w[i].s<<endl;
			order=i;
		}
		else if(c[0]=='B')
		{
			j=w[order].back;
			if(j+1)
			{
				cout<<w[j].s<<endl;
				w[j].ford=order;
				order=j;
				}
			else cout<<"Ignored"<<endl;
		
		}
		else
		{
			if(w[order].ford+1)
			{
				cout<<w[w[order].ford].s<<endl;
				w[w[order].ford].back=order;
				order=w[order].ford;
			}
			else cout<<"Ignored"<<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