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 wocha at 2012-09-04 18:37:09 on Problem 1028
#include <iostream>
#include <stack>
#include <string>
using namespace std;
int main(){
	stack<string> stack1,stack2;            string str,s1,s2;  
    str="http://www.acm.org/";              stack1.push(str);
	while(cin>>s1){
		if(s1=="QUIT")                      break;
		if(s1=="VISIT"){
			cin>>s2;   cout<<s2<<endl;	    stack1.push(s2);  
			while(!stack2.empty())          stack2.pop();
		} else if(s1=="BACK"){
			if(stack1.size()>=2){  
			stack2.push(stack1.top());      stack1.pop();
            cout<<stack1.top()<<endl;	
			} else                          puts("Ignored");
		  } else {
			if(!stack2.empty()){
				cout<<stack2.top()<<endl;
		        stack1.push(stack2.top());  stack2.pop(); 	 
			} else   	                    puts("Ignored");
		}
	}	
	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