求助!!!
  • 板块灌水区
  • 楼主_colin1112_
  • 当前回复4
  • 已保存回复4
  • 发布时间2023/2/5 14:22
  • 上次更新2023/10/24 01:38:12
查看原帖
求助!!!
904032
_colin1112_楼主2023/2/5 14:22

题目

#include <iostream>
#include <stack>
#include <queue>
using namespace std;
long long n;
long long m;
stack<int> stk;
string a;
int main(){
	cin >>n;
	for(int i=0;i<n;i++){
		cin >>m;
		for(int i=0;i<m;i++){
			cin >>a;
			if(a=="push"){
				long long x;
				cin >>x;
				stk.push(x);
			}
			else if(a=="pop"){
				if(stk.empty()==1){
					cout <<"Empty"<<endl;
				}
				else{
					stk.pop();
				}
			}
			else if(a=="size"){
				cout <<stk.size()<<endl;
			}
			else if(a=="query"){
				if(stk.empty()==1){
					cout <<"Anguei!"<<endl;
				}
				else{
					cout <<stk.top()<<endl;
				}
			}
		}
	}
	return 0;
}

这哪里错了啊,33分

2023/2/5 14:22
加载中...