• poj 1028 (STL)


    题目链接: http://poj.org/problem?id=1028

        4、5个月前就做这题了,当时是用数组模拟的,结果RE到吐血!这次直接用STL模板,一次AC!文盲的悲哀啊!

     

    #include<iostream>
    #include
    <fstream>
    #include
    <string>
    #include
    <stack>
    using namespace std ;
    int main(){
        stack
    <string> a ;
        stack
    <string> b ;           //b记录BACK操作前的页面
        string c ;
        a.push(
    "http://www.acm.org/") ;
        
    //fstream cin("x.in") ;
        while(cin>>c&&c!="QUIT"){
            
    if(c=="VISIT"){
                cin 
    >> c ;
                a.push(c) ;
                
    while(!b.empty())   b.pop() ; //b不为空则将b清空
                cout << c << endl ;
            }
    else
            
    if(c=="BACK"){
                c 
    = a.top() ;
                a.pop() ;
                
    if(a.empty()){
                    cout 
    << "Ignored" << endl ;
                    a.push(c) ;
                }
                
    else{
                    cout 
    << a.top() << endl ;
                    b.push(c) ;
                }
            }
    else{
                
    if(b.empty())   cout << "Ignored" << endl ;
                
    else{
                    cout 
    << b.top() << endl ;
                    a.push(b.top()) ;
                    b.pop() ;
                }
            }
        }
        
    return 0 ;
    }

     

     

  • 相关阅读:
    A站C值电影列表 4月27号更新
    【dmp文件还原到oralce数据库】
    批量上传图片
    Repeater嵌套
    生成json格式
    C#汉字转为Unicode编码
    Jquery+json绑定带层次下拉框(select控件)
    Asp.net绑定带层次下拉框(select控件)
    从数据库里面取值绑定到Ztree
    根据参数显示类别(三级联动,需要JSON数据)
  • 原文地址:https://www.cnblogs.com/xiaolongchase/p/2181855.html
Copyright © 2020-2023  润新知