POJ 1028

#include<iostream>
using namespace std;
#define Len     3
#include<string>
int main(){
   int i,d=1,index=0,box_max=0;
    string * pack=new string[Len];
    string * p;
    pack[0]="http://www.acm.org/";
    string comand_s=" ";
   do{
      cin>>comand_s;
  // cout<<comand_s<<endl;
   if(comand_s=="VISIT"){
       index++;
       cin>>pack[index];
       cout<<pack[index]<<endl;
           box_max=index;
       if(index==Len*d-2){
           d++;
         p=pack;
         pack=new string[Len*d];
         
         pack[0]=" ";
         for(i=0;i<Len*(d-1);i++){
             swap(p[i],pack[i]);
             
         }
         delete []p;//////////////////////////最后的调试
        // cout<<"------"<<endl;  这招挺管用的
       }
   }
   if(comand_s=="BACK"){
      index--;
      if(index==-1){
          cout<<"Ignored"<<endl;
          index++;
      }
      else
          cout<<pack[index]<<endl;
   }
   if(comand_s=="FORWARD"){
      index++;
      if(index>box_max){
          cout<<"Ignored"<<endl;
          index--;
      }
      else
          cout<<pack[index]<<endl;
   }
   if(comand_s=="QUIT")
       return 0;
   }while(1);
   return 0;

}

关注我的公众号,当然,如果你对Java, Scala, Python等技术经验,以及编程日记,感兴趣的话。 

技术网站地址: vmfor.com




原文地址:https://www.cnblogs.com/gavinsp/p/4563218.html