题目如下:
我使用的知识点是STL,如有兴趣的,可以看我总结的这一篇,有关STL的知识点。
STL的知识点https://blog.csdn.net/m0_67500944/article/details/126904238?spm=1001.2014.3001.5502
代码如下:
#include<iostream>
#include<stack>
using namespace std;
int main(){
stack<int> s;
char ch;
int n;
cin>>ch;
while(ch!='E'){
if(ch=='P'){
cin>>n;
s.push(n);
}
if(ch=='T'){
while(!s.empty()){
s.pop();
}
}
if(ch=='Y'){
if(s.empty()){
cout<<"yes";
}else{
cout<<"no";
}
}
if(ch=='G'){
if(s.empty()){
cout<<"None";
}else
cout<<s.top();
}
if(ch=='D'){
if(s.empty()){
cout<<"None";
}else{
cout<<s.top();
s.pop();
}
}
cin>>ch;
}
return 0;
}