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

why wrong?

Posted by rudylau at 2009-02-28 15:37:32 on Problem 1028
#include<iostream>
#include<string>
using namespace std;
char w[210][80];
int co,i;
char na[100],*p;
void BACK();
void FORWARD();
void VISIT();
int main()
{	
	strcpy(w[0],"http://www.acm.org/");
	co=i=0;
	while(cin.getline(na,100))
	{
		if(strcmp(na,"QUIT")==0)break;
		if(na[0]=='B')BACK();
		if(na[0]=='F')FORWARD();
		if(na[0]=='V')VISIT();	 
	}
	return 0;
}
void BACK()
{
	if(i==0)
	{
		cout<<"Ignored\n";
		return;
	}
	i--;
	cout<<w[i]<<endl;
}
void FORWARD()
{
	if(i==co)
	{
		cout<<"Ignored\n";
		return;
	}
	i++;
	cout<<w[i]<<endl;
}
void VISIT()
{
	if(i==co)co++;
	i++;
	p=&na[6];
	strcpy(w[i],p);
	cout<<w[i]<<endl;
}

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