View Code of Problem 163

#include<iostream>
using namespace std;
int main(){
	string s[200],str;
	s[0]="http://www.acm.org/";
	int L=0,R=0;
	int p=0;
	while(cin>>str&&str!="QUIT"){
		if(str=="VISIT"){
			string cmd;
			cin>>cmd;
			cout<<cmd<<endl;
			p++;
			R=p;
			s[R]=cmd;
		}
		else if(str=="BACK"){
			if(p>0){
				p--;
				cout<<s[p]<<endl;
			}
			else
			cout<<"Ignored"<<endl;
		}
		else if(str=="FORWARD"){
			if(p<R){
				p++;
				cout<<s[p]<<endl;
			}
			else
			cout<<"Ignored"<<endl;
		}
	}
	
	return 0;
}

Double click to view unformatted code.


Back to problem 163