Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
很简单的code 为什么会WA呢 求高人#include<iostream> #include<string> using namespace std; struct Stack { string str[200]; int top; }; void Push(Stack *&s,string str1) { s->top++; s->str[s->top]=str1; } void Pop(Stack *&s,string &str1) { str1=s->str[s->top]; s->top--; } int main() { const string HP="http://www.acm.org/"; string cmd; string cstr=HP; Stack *sb=new Stack();sb->top=-1; Stack *sf=new Stack();sf->top=-1; while(cin>>cmd) { if(cmd=="QUIT") break; if(cmd=="BACK") { if(cstr!=HP)Push(sf,cstr); if(sb->top==-1) cout<<"Ignored"<<endl; else { Pop(sb,cstr); cout<<cstr<<endl; } } if(cmd=="FORWARD") { Push(sb,cstr); if(sf->top==-1) cout<<"Ignored"<<endl; else{Pop(sf,cstr);cout<<cstr<<endl;} } if(cmd=="VISIT") { Push(sb,cstr); cin>>cstr; cout<<cstr<<endl; sf->top=-1; } } // system("pause"); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator