#include<iostream>
using namespace std;
const int N=100010;
int stack[N],top;
int main()
{
int m;
cin>>m;
while(m--)
{
string opration;
int x;
cin>>opration;
if(opration == "push")
{
cin>>x;
stack[top++]=x;
}
else if(opration == "pop")
--top;
else if(opration == "empty")
if(top) printf("NO\n");
else printf("YES\n");
else
cout<<stack[top-1]<<endl;
}
return 0;
}
不能用stack定义吧
没有导入stack头文件是可以用stack定义的
好吧,我当时用的万能头,,结果报错了,hh
感谢分享