| ||||||||||
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 |
高人,小弟实在是找不出错来了,结果运行也正确,可是总是提示答案错误#include<iostream> #include<stack> #include<string> using namespace std; int main(){ stack<string> forward_stack; stack<string> backforword_stack; string state; string address; backforword_stack.push("http://www.acm.org/"); while(1){ cin>>state; int i; if(state=="QUIT"){ return 0; } else if(state=="VISIT"){ i=0; cin>>address; backforword_stack.push(address); cout<<address<<endl; while(!forward_stack.empty()) forward_stack.pop(); } else if(state=="BACK"){ if(backforword_stack.size()<=1){ address="Ignored"; } else{ if(i==0){ forward_stack.push(backforword_stack.top()); } i++; backforword_stack.pop(); address=backforword_stack.top(); forward_stack.push(address); } cout<<address<<endl; } else if(state=="FORWARD"){ i=0; if(forward_stack.size()<=1){ address="Ignored"; } else{ if(forward_stack.size()==1){ address=forward_stack.top(); forward_stack.pop(); } else{ forward_stack.pop(); address=forward_stack.top(); } backforword_stack.push(address); } cout<<address<<endl; } } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator