Exemplo n.º 1
0
void app_run()
{
	char ch;	

	while(1)
	{	
		app_menu();	
		ch=getch();			
		switch(ch)
		{
			case '1':	front_push();				break;
			case '2':	back_push();				break;
			case '3':	front_pop();				break;
			case '4':	back_pop();					break;
			case '5':   return;
		}		
		system("pause");
	}
}
int main()
{
   // freopen("input.txt","r",stdin);

    int t,i;
    char command[15],input[55],current[55];

    scanf("%d",&t);
    getchar();

    for(i=1;i<=t;i++)
    {
        strcpy(current,"http://www.lightoj.com/");
        for_clr();
        back_clr();

        printf("Case %d:\n",i);

        while(1)
        {
            scanf("%s",command);
           // puts(command);

            if(strcmp(command,"VISIT")==0)
            {
                scanf("%s",input);
              //  puts(input);

                back_push(current);
                for_clr();

                strcpy(current,input);
                puts(current);
            }

            else if(strcmp(command,"BACK")==0)
            {
                if(back_top==0)
                {
                    printf("Ignored\n");
                    continue;
                }
                else
                {
                    for_push(current);
                    back_pop(current);
                }
                puts(current);
            }
            else if(strcmp(command,"FORWARD")==0)
            {
                if(for_top==0)
                {
                    printf("Ignored\n");
                    continue;
                }
                else
                {
                    back_push(current);
                    for_pop(current);
                }
                puts(current);
            }
            else if(strcmp(command,"QUIT")==0)
            {
                break;
            }
        }
    }
    return 0;
}