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 |
请高手帮助看一下为什么总是time limited exceeded 啊?#include <iostream> #define MAXLENGTH 100 using namespace std; struct BACK { char URL[MAXLENGTH][75]; int top; }; struct FORWARD { char URL[MAXLENGTH][75]; int top; }; int main() { struct BACK back; struct FORWARD forward; back.top = MAXLENGTH; forward.top = MAXLENGTH; if (back.top != 0) { back.top = back.top - 1; strcpy(back.URL[back.top] , "http://www.acm.org/"); } //push("http://www.acm.org/",back); char command[10]; cin>>command; while (strcmp(command , "QIUT") != 0) { if (strcmp(command , "VISIT") == 0) { char U[75]; cin>>U; back.top = back.top - 1; strcpy(back.URL[back.top] , U); //push(U,back); cout<<back.URL[back.top]<<endl; } else if (strcmp(command , "BACK") == 0) { if ((back.top + 1) <= (MAXLENGTH - 1)) { forward.top = forward.top - 1; strcpy(forward.URL[forward.top] , back.URL[back.top]); //push(back.URL[back.top],forward); cout<<back.URL[back.top + 1]<<endl; back.top = back.top + 1; //pop(back); } else { cout<<"Ignored"<<endl; } } else if (strcmp(command , "FORWARD") == 0) { if (forward.top <= MAXLENGTH - 1) { back.top = back.top - 1; strcpy(back.URL[back.top] , forward.URL[forward.top]); //push(forward.URL[forward.top],back); cout<<forward.URL[forward.top]<<endl; forward.top = forward.top + 1; //pop(forward); } else { cout<<"Ignored"<<endl; } } cin>>command; } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator