本文主要是介绍堆栈的使用【吉林大学】,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
题目链接
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e4+5;
int arr[maxn];
int main(){int n,x;char c;while(cin>>n){int k=0;for(int i=0;i<n;i++){cin>>c;if(c=='P'){cin>>x;arr[k++]=x;}else if(c=='A'){if(k-1 < 0) cout<<"E"<<endl;else cout<<arr[k-1]<<endl;}else if(c=='O'){if(k<1) continue;else k--;} }cout<<endl;}return 0;
}
这篇关于堆栈的使用【吉林大学】的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!