zoukankan      html  css  js  c++  java
  • poj1028 Web Navigation

    Accepted 360K 16MS G++ 700B
     1 #include<stdio.h>
     2 #include<string.h>
     3 char fs[100][71],bs[100][71];
     4 int ftop,btop;
     5 int main()
     6 {
     7     char a[8],cur[71];
     8     strcpy(cur,"http://www.acm.org/");
     9     while(scanf("%s",a),strcmp(a,"QUIT")){
    10         if(!strcmp(a,"VISIT")){
    11             strcpy(bs[btop++],cur);
    12             scanf("%s",cur);
    13             puts(cur);
    14             ftop=0;
    15         }
    16         else if(!strcmp(a,"FORWARD")){    
    17             if(ftop){
    18                 strcpy(bs[btop++],cur);
    19                 strcpy(cur,fs[--ftop]);
    20                 puts(cur);
    21             }
    22             else puts("Ignored");
    23         }
    24         else if(!strcmp(a,"BACK")){
    25             if(btop){
    26                 strcpy(fs[ftop++],cur);
    27                 strcpy(cur,bs[--btop]);
    28                 puts(cur);
    29             }
    30             else puts("Ignored");
    31         }
    32     }
    33     return 0;
    34 }
    Accepted 688K 32MS G++ 564B
     1 #include<iostream>
     2 using namespace std;
     3 string fs[100],bs[100];
     4 int ftop,btop;
     5 int main()
     6 {
     7     string a,cur;
     8     cur="http://www.acm.org/";
     9     while(cin>>a,a!="QUIT"){
    10         if(a=="VISIT"){
    11             bs[btop++]=cur;
    12             cin>>cur;
    13             cout<<cur<<endl;
    14             ftop=0;
    15         }
    16         else if(a=="FORWARD"){    
    17             if(ftop){
    18                 bs[btop++]=cur;
    19                 cur=fs[--ftop];
    20                 cout<<cur<<endl;
    21             }
    22             else cout<<"Ignored\n";
    23         }
    24         else if(a=="BACK"){
    25             if(btop){
    26                 fs[ftop++]=cur;
    27                 cur=bs[--btop];
    28                 cout<<cur<<endl;
    29             }
    30             else cout<<"Ignored\n";
    31         }
    32     }
    33     return 0;
    34 }
  • 相关阅读:
    NCBI SRA数据库使用详解
    自相关分析
    RandomAccessFile java
    手动安装R包
    ubuntu 设置环境变量
    Shell:Day09-2.笔记
    Shell:Day09.笔记
    Shell:Day08.笔记
    Shell:Day07.笔记
    Shell:Day06.笔记
  • 原文地址:https://www.cnblogs.com/shihuajie/p/2626923.html
Copyright © 2011-2022 走看看