| ||||||||||
| 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 | |||||||||
终于AC,我是个C++初学者.觉得代码还有很大问题,特贴上,望各位修改........Source Code
Problem: 1028 User: qichao
Memory: 224K Time: 47MS
Language: C++ Result: Accepted
Source Code
#include<iostream>
#include<stack>
#include<string>
#include<cstring>
using namespace std;
int main()
{
stack<string> forward,back;
char *c1="http://www.acm.org/";
string basic(c1);
char *c2[4]={"QUIT","VISIT","BACK","FORWARD"};
string current(c1),order;
while(cin>>order&&order.compare(c2[0]))
{
if(!order.compare(c2[1]))
{
back.push(current);
cin>>current;
cout<<current<<endl;
while(!forward.empty())
forward.pop();
}
else if(!order.compare(c2[2]))
{
if(current!=basic)
forward.push(current);
if(!back.empty())
{
current=back.top();
back.pop();
cout<<current<<endl;
}
else
cout<<"Ignored"<<endl;
}
else if(!order.compare(c2[3]))
{
if(!forward.empty())
{
back.push(current);
current=forward.top();
forward.pop();
cout<<current<<endl;
}
else
cout<<"Ignored"<<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