zoukankan      html  css  js  c++  java
  • 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 ;
    }

     

     

  • 相关阅读:
    Log4Net 发布后不能用
    主机ping不通虚拟机
    c# Delegate 和 Events
    ADO.NET
    .NET Windows Service
    Linux 常用命令三 touch mkdir
    Linux 常用命令二 pwd cd
    Linux 常用命令一 ls
    python 面向对象六 动态添加方法 __slots__限制动态添加方法
    python 面向对象六 类属性和实例属性
  • 原文地址:https://www.cnblogs.com/xiaolongchase/p/2181855.html
Copyright © 2011-2022 走看看