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:用STL实现的代码,不足之处请指正…………

Posted by visual at 2006-04-08 12:38:36 on Problem 1028
In Reply To:用STL实现的代码,不足之处请指正………… Posted by:visual at 2006-04-08 12:37:57
> #include<iostream>
> #include<stack>
> #include<string>
> #include<algorithm>
> 
> using namespace std;
> 
> int main()
> {
>     int flag;
>     stack<string> back;
>     stack<string> next;
>    
>     string temp="http://www.acm.org/";
>     string current;
>     while(getline(cin,current))
>     {
>            if(current=="QUIT") 
>            break; 
>            
>            else   if(current=="BACK")
>            {
>                if(back.empty())
>                cout<<"Ignored"<<endl;
>                else
>                {
>                cout<<back.top()<<endl;  
>                next.push(temp);
>                temp = back.top(); 
>                back.pop(); 
>                }            
>            } 
>            
>             else   if(current=="FORWARD")
>             {
>                if(next.empty())
>                cout<<"Ignored"<<endl;
>                else
>                {
>                    cout<<next.top()<<endl;
>                    back.push(temp);
>                    temp = next.top();
>                    next.pop(); 
>                }  
>             }
>             
>             else if(flag=current.find("VISIT") != string::npos)
>             {
>                // cout<<flag<<endl; 
>               flag = current.find_last_of(" ");//×&cent;&Ograve;&acirc;&Aring;&para;&Otilde;&acirc;&Agrave;&iuml;&micro;&Auml;&Oacute;&Atilde;·¨&pound;&iexcl; 
>             //  cout<<flag<<endl;
>               back.push(temp);
>               temp = current.substr(flag+1) ;
>              while(!next.empty()) next.pop();
>              
>               cout<<temp<<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