蒟蒻33分求助qwq
查看原帖
蒟蒻33分求助qwq
942205
feizhaishui666楼主2023/8/25 11:18
#include <bits/stdc++.h>
using namespace std;
int t;
int n;
string c;
int x;
stack<int> stk;
int main(){
    cin >> t;
    for(int i=0;i<t;i++){
    	cin >> n;
    	for(int j=0;j<n;j++){
    		cin >> c;
	        if(c=="push"){
	            cin >> x;
	            stk.push(x);
	        }
	        else if(c=="pop"){
	            if(stk.empty()){
	                cout << "Empty" << endl;
	            }
	            else{
	                stk.pop();
	            }
	        }
	        else if(c=="query"){
	            if(stk.empty()){
	                cout << "Anguei!" << endl;
	            }
	            else{
	                cout << stk.top() << endl;
	            }
	        }
	        else if(c=="size"){
	            cout << stk.size() << endl;
	        }
		}
        
    }
    return 0;
}

第一个测试点过了 后两个WA

2023/8/25 11:18
加载中...