标签:des c style class blog code
Description
Input
Output
Sample Input
VISIT http://acm.ashland.edu/ VISIT http://acm.baylor.edu/acmicpc/ BACK BACK BACK FORWARD VISIT http://www.ibm.com/ BACK BACK FORWARD FORWARD FORWARD QUIT
Sample Output
http://acm.ashland.edu/ http://acm.baylor.edu/acmicpc/ http://acm.ashland.edu/ http://www.acm.org/ Ignored http://acm.ashland.edu/ http://www.ibm.com/ http://acm.ashland.edu/ http://www.acm.org/ http://acm.ashland.edu/ http://www.ibm.com/ Ignored
1 Source Code 2 3 Problem: 1028 User: 13408100238 4 Memory: 200K Time: 0MS 5 Language: C++ Result: Accepted 6 Source Code 7 #include"iostream" 8 #include"cstring" 9 #include"string" 10 #include"stack" 11 using namespace std; 12 int main() 13 { 14 stack<string> s1,s2; 15 string s,ss; 16 s="http://www.acm.org/"; 17 s1.push(s); 18 while(cin>>s) 19 { 20 if(s=="QUIT") 21 break; 22 if(s=="VISIT") 23 { 24 cin>>ss; 25 cout<<ss<<endl; 26 s1.push(ss); 27 while(!s2.empty()) 28 s2.pop(); 29 } 30 else if(s=="BACK") 31 { 32 //cout<<"back "<<s1.size()<<endl; 33 if(s1.size()>=2) 34 { 35 s2.push(s1.top()); 36 s1.pop(); 37 cout<<s1.top()<<endl; 38 } 39 else 40 cout<<"Ignored"<<endl; 41 } 42 else if(s=="FORWARD") 43 { 44 if(!s2.empty()) 45 { 46 cout<<s2.top()<<endl; 47 s1.push(s2.top()); 48 s2.pop(); 49 } 50 else 51 cout<<"Ignored"<<endl; 52 } 53 } 54 return 0; 55 }
标签:des c style class blog code
原文地址:http://www.cnblogs.com/767355675hutaishi/p/3760922.html