Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

几个测试结果都对啊,为嘛还WA???

Posted by xp94 at 2014-03-26 22:12:00 on Problem 1028
几个测试结果都对啊,为嘛还WA???

#include <iostream>
#include<stdio.h>
#include <string>
using namespace std;
#define OK 0;
typedef string SElemtype;
typedef int Status;
typedef struct StackNode
{
    SElemtype data;
    struct StackNode *next;
} StackNode,*LinkStack;
Status InitStack(LinkStack &S)
{
    S=NULL;
    return OK;
}
Status Push(LinkStack &S,SElemtype e)
{
    LinkStack p=new StackNode;
    p->data=e;
    p->next=S;
    S=p;
    return OK;
}
Status Pop(LinkStack &S,SElemtype &e)
{
    if(S==NULL) return -1;
    LinkStack p=NULL;
    e=S->data;
    p=S;
    S=S->next;
    delete p;
    return OK;
}
Status clean(LinkStack &S)
{
    S=NULL;
    return OK;
}
int main()
{
    //freopen("data.txt", "rb", stdin);
    string  command,temp,show="http://www.acm.org/";
    int select;
    LinkStack Backward,Forward;
    InitStack(Backward);
    InitStack(Forward);
    for(;;)
    {
            cin>>command;
            int Ignored=0;
            if(command=="QUIT") break;
            if(command=="VISIT") select=1;
            if(command=="BACK") select=2;
            if(command=="FORWARD") select=3;
            switch(select)
            {
            case 1:Push(Backward,show);cin>>show;clean(Forward);
                break;
            case 2:Push(Forward,show);
                      if(Pop(Backward,show)==-1)
                      {
                          Pop(Forward,show);
                          Push(Backward,show);
                          cout<<"Ignored\n";
                          Ignored=1;
                      }
                break;
            case 3:Push(Backward,show);
                      if(Pop(Forward,show)==-1)
                      {
                          Pop(Backward,show);
                          Push(Forward,show);
                          cout<<"Ignored\n";
                          Ignored=1;
                      }

                break;
                default:break;
            }
            if(Ignored==0)
               cout<<show<<"\n";
    }
    return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator