全部WA,求dalao帮忙
查看原帖
全部WA,求dalao帮忙
357378
ajahjahah楼主2020/10/10 18:58
#include<bits/stdc++.h>
using namespace std;
int main(){
	stack <int> a;
	int type,weight,n;
	cin>>n;
	for(int i=0;i<=n-1;i++){
		cin>>type;
		if(type==0){
			cin>>weight;
			a.push(weight);
		}
		else if(type==1&&!a.empty()){
			a.pop();
		}
		else if(a.empty()){
			printf("0\n");
		}
		else{
			printf("%d\n",a.top());
		}
	}
	return 0;
}

2020/10/10 18:58
加载中...