青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

posts - 21, comments - 2, trackbacks - 0, articles - 0

ZOJ 1061 Web Navigation_數據結構_棧

Posted on 2011-09-05 22:47 acpeng 閱讀(583) 評論(0)  編輯 收藏 引用 所屬分類: ACM程序
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=61
數據結構,用C寫的棧,不用STL確實復雜多了,WA了幾次~
Standard web browsers contain features to move backward and forward among the pages recently visited. One way to implement these features is to use two stacks to keep track of the pages that can be reached by moving backward and forward. In this problem, you are asked to implement this.

The following commands need to be supported:

BACK: Push the current page on the top of the forward stack. Pop the page from the top of the backward stack, making it the new current page. If the backward stack is empty, the command is ignored.

FORWARD: Push the current page on the top of the backward stack. Pop the page from the top of the forward stack, making it the new current page. If the forward stack is empty, the command is ignored.

VISIT <url>: Push the current page on the top of the backward stack, and make the URL specified the new current page. The forward stack is emptied.

QUIT: Quit the browser.

Assume that the browser initially loads the web page at the URL http://www.acm.org/


This problem contains multiple test cases!

The first line of a multiple input is an integer N, then a blank line followed by N input blocks. Each input block is in the format indicated in the problem description. There is a blank line between input blocks.

The output format consists of N output blocks. There is a blank line between output blocks.


Input

Input is a sequence of commands. The command keywords BACK, FORWARD, VISIT, and QUIT are all in uppercase. URLs have no whitespace and have at most 70 characters. You may assume that no problem instance requires more than 100 elements in each stack at any time. The end of input is indicated by the QUIT command.

Output

For each command other than QUIT, print the URL of the current page after the command is executed if the command is not ignored. Otherwise, print "Ignored". The output for each command should be printed on its own line. No output is produced for the QUIT command.

Sample Input

1

VISIT http://acm.ashland.edu/
VISIT http://acm.baylor.edu/acmicpc/
BACK
BACK
BACK
FORWARD
VISIT http://www.ibm.com/
BACK
BACK
FORWARD
FORWARD
FORWARD
QUIT

Sample Output

http://acm.ashland.edu/
http://acm.baylor.edu/acmicpc/
http://acm.ashland.edu/
http://www.acm.org/
Ignored
http://acm.ashland.edu/
http://www.ibm.com/
http://acm.ashland.edu/
http://www.acm.org/
http://acm.ashland.edu/
http://www.ibm.com/
Ignored

AC代碼:

#include<stdio.h>
#include
<string.h>
#include
<malloc.h>
#define StackSize 105
typedef 
struct
{
    
char elemt[StackSize][73];
    
int top;
}
Stack;
void InitStack(Stack *S)
{
      S
->top=-1;
}

int ElemtNum(Stack *S)
{
    
return (S->top)+1;
}

int IsFull(Stack *S)
{
    
return(S->top==StackSize-1?1:0);
}

int PushStack(Stack *S,char *x)
{
    
if(IsFull(S))  
        
return 0;
    S
->top++;
    memset(S
->elemt[S->top],'\0',sizeof(S->elemt[S->top]));
    strcpy(S
->elemt[S->top],x);
    
return 1;
}

int PopStack(Stack *S,char *x)
{  
    
if(ElemtNum(S)==0)
        
return 0;
    memset(x,
0,sizeof(x));
      strcpy(x,S
->elemt[S->top]);
    memset(S
->elemt[S->top],0,sizeof(S->elemt[S->top]));
    S
->top--;
      
return 1;
}

int GetTopElemt(Stack *S,char *x)
{
    
if(ElemtNum(S)==0)
        
return 0;
      memset(x,
0,sizeof(x));
      strcpy(x,S
->elemt[S->top]);
      
return 1;
}

int main()
{
    Stack 
*sBack,*sForward;
    sBack
=(Stack *)malloc(sizeof(Stack));
    sForward
=(Stack *)malloc(sizeof(Stack));
    
int T;char str[73]="\0",comd[8]="\0",tmp[73]="\0";
    scanf(
"%d",&T);
    
while(T--)
    
{
        InitStack(sBack); InitStack(sForward);
        PushStack(sBack,
"http://www.acm.org/");
        
while(1)
        
{
            memset(comd,
0,sizeof(comd));
            scanf(
"%s",comd);
            
if(strcmp(comd,"BACK")==0)
            
{
                
if(ElemtNum(sBack)==1)
                
{
                    printf(
"Ignored\n");
                    
continue;
                }

                PopStack(sBack,tmp);
                PushStack(sForward,tmp);
                
if(GetTopElemt(sBack,tmp)==1)
                    printf(
"%s\n",tmp);
            }

            
else if(strcmp(comd,"FORWARD")==0)
            
{
                
if(ElemtNum(sForward)==0)
                
{
                    printf(
"Ignored\n");
                    
continue;
                }

                PopStack(sForward,tmp);
                PushStack(sBack,tmp);
                
if(GetTopElemt(sBack,tmp)==1)
                    printf(
"%s\n",tmp);
            }

            
else if(strcmp(comd,"VISIT")==0)
            
{
                memset(str,
0,sizeof(str));
                scanf(
"%s",str);
                printf(
"%s\n",str);
                PushStack(sBack,str);
                InitStack(sForward);
            }

            
else if(strcmp(comd,"QUIT")==0)
                
break;
        }

        
if(T>0) printf("\n");
    }

    free(sBack);free(sForward);
    
return 0;
}


青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            欧美激情成人在线视频| 久久亚洲春色中文字幕久久久| 亚洲国产日韩欧美一区二区三区| 国产欧美一区二区白浆黑人| 国产精品久久久久一区二区三区| 国产精品亚洲综合一区在线观看 | 一区二区欧美在线观看| 一区二区三区黄色| 国产精品成人av性教育| 欧美精品一区二区三区视频| 欧美色图五月天| 国产一区在线播放| 日韩午夜在线播放| 欧美在线观看视频一区二区| 免费91麻豆精品国产自产在线观看| 亚洲第一精品夜夜躁人人躁| 欧美一区1区三区3区公司| 久热精品视频在线观看一区| 国产精品免费视频xxxx| 久久精品国产精品 | 亚洲午夜精品久久久久久app| 性色av一区二区三区| 亚洲激情国产| 久久免费国产精品| 一区二区日本视频| 亚洲第一区中文99精品| 欧美美女操人视频| 亚洲欧美亚洲| 亚洲精品欧美激情| 亚洲欧洲一级| 欧美在线一二三| 久久精品色图| 免费成人高清在线视频| 欧美不卡在线视频| 国产精品手机在线| 麻豆国产精品777777在线| 久久全国免费视频| 亚洲欧美色一区| 欧美中文字幕视频在线观看| 亚洲国产精品激情在线观看| 亚洲国产欧美一区二区三区久久| 欧美一区三区三区高中清蜜桃| 小嫩嫩精品导航| 欧美精品激情blacked18| 国产一区二区三区最好精华液| 麻豆成人在线观看| 欧美亚州一区二区三区| 午夜欧美不卡精品aaaaa| 久久成人av少妇免费| 欧美精品综合| 欧美一级电影久久| 欧美激情一区在线| 久久国产精品亚洲77777| 欧美fxxxxxx另类| 国产精品手机在线| 亚洲激情网址| 狠狠色丁香婷婷综合久久片| 亚洲日本在线视频观看| 中文在线资源观看网站视频免费不卡 | 久久久久久网站| 亚洲精品一区二区三区99| 好看不卡的中文字幕| 亚洲免费观看高清完整版在线观看熊| 国产亚洲精品aa| 一本色道久久综合亚洲精品不| 一区二区三区在线视频观看| 亚洲一区二区三区中文字幕 | 狼人天天伊人久久| 欧美亚洲免费电影| 欧美区二区三区| 欧美成人激情在线| 国产主播一区二区三区四区| 亚洲午夜精品| 欧美日本精品一区二区三区| 美国十次了思思久久精品导航| 国产精品视频一区二区三区| 亚洲美女免费视频| 亚洲精品一区二区三区四区高清| 久久久久久久久久久久久女国产乱 | 久久青草久久| 麻豆精品一区二区综合av| 国产精品亚洲一区二区三区在线| 一区二区欧美日韩视频| 日韩视频在线永久播放| 欧美不卡视频一区发布| 欧美大胆成人| 久久久久看片| 欧美aaa级| 亚洲国产精品99久久久久久久久| 久久成人人人人精品欧| 久久精品一二三区| 欧美黄色影院| 亚洲精品一区二区三区99| 99香蕉国产精品偷在线观看| 欧美精品黄色| 裸体素人女欧美日韩| 国产一区二区精品久久99| 欧美亚洲综合在线| 久久久久国产精品www| 国产一区二区在线免费观看 | 欧美一区二区三区免费观看| 国产欧美日韩不卡| 香蕉免费一区二区三区在线观看 | 在线观看欧美亚洲| 欧美成人精品激情在线观看| 亚洲精品一级| 欧美一区二区三区在| 国产日韩一区二区三区在线播放 | 亚洲一二三区在线| 国产精品欧美一区二区三区奶水| 亚洲欧洲av一区二区三区久久| 久久精品91久久久久久再现| 精品1区2区| 欧美日韩亚洲激情| 亚洲欧美日韩在线不卡| 欧美xart系列高清| 夜夜嗨av一区二区三区中文字幕| 欧美成人免费va影院高清| 99re成人精品视频| 欧美亚洲午夜视频在线观看| 国产在线精品自拍| 免费成年人欧美视频| 亚洲天堂黄色| 欧美成人亚洲成人| 亚洲欧美日韩中文视频| 在线日韩电影| 欧美午夜精品理论片a级大开眼界| 欧美在线亚洲一区| 99视频在线观看一区三区| 久久中文字幕一区| 亚洲一区3d动漫同人无遮挡| 在线观看成人av| 国产精品乱码一区二区三区 | 麻豆精品一区二区av白丝在线| 99国产精品| 欧美日韩免费看| 乱人伦精品视频在线观看| 亚洲欧美日本伦理| 亚洲精品看片| 久久综合影视| 欧美在线一二三四区| 夜夜嗨av色一区二区不卡| 在线观看91精品国产麻豆| 国产乱码精品一区二区三区五月婷| 欧美成人免费全部| 久久综合久久久| 欧美一区二区三区四区视频| 一本大道久久a久久精品综合| 亚洲大胆在线| 蜜月aⅴ免费一区二区三区| 久久精品日韩| 欧美一区91| 又紧又大又爽精品一区二区| 欧美午夜电影在线观看| 欧美午夜精品久久久久久久 | 日韩亚洲欧美成人| 亚洲人屁股眼子交8| 亚洲国产精品一区制服丝袜 | 亚洲第一精品在线| 国产视频在线一区二区| 国产精品久久久亚洲一区| 欧美午夜激情在线| 欧美视频免费在线观看| 欧美日韩高清免费| 欧美日韩精品欧美日韩精品一| 欧美黄色影院| 欧美日本高清| 欧美午夜片欧美片在线观看| 欧美色精品天天在线观看视频| 欧美日韩国产欧| 免费成人高清视频| 欧美激情一区二区三区全黄 | 亚洲免费视频中文字幕| 性伦欧美刺激片在线观看| 亚洲一区二区毛片| 性做久久久久久久久| 久久久av水蜜桃| 麻豆九一精品爱看视频在线观看免费| 免费成人美女女| 欧美日韩成人综合在线一区二区| 欧美日韩国产影片| 国产精品久久看| 国产综合色精品一区二区三区| 国产一区二区三区黄| 影音先锋亚洲精品| 亚洲精品乱码久久久久久日本蜜臀| 日韩午夜高潮| 性一交一乱一区二区洋洋av| 久久精品亚洲乱码伦伦中文 | 亚洲片国产一区一级在线观看| 亚洲国内自拍| 亚洲小少妇裸体bbw| 欧美一区二区在线免费观看| 麻豆乱码国产一区二区三区| 最新日韩精品| 欧美一区2区视频在线观看 | 亚洲精品资源| 亚洲欧美久久久久一区二区三区| 久久精品亚洲一区二区三区浴池| 欧美激情a∨在线视频播放|