C++33分,大佬求调
查看原帖
C++33分,大佬求调
756773
lzx0楼主2023/2/5 18:10

求大佬看看

#include<bits/stdc++.h> 
using namespace std;
stack<int> s; 
int main() 
{
	unsigned long long x,t,n;
	scanf("%llu",&t);
	for(int ii=1;ii<=t;ii++){
	scanf("%llu",&n);
	for(int i=0;i<n;i++){
	string z;
	cin>>z; 
	if(z=="push"){
		scanf("%llu",&x);
		s.push(x);
	}
    else if(z=="pop"){
    	if(!s.empty()){	
		 s.pop();
	    }
    	else cout<<"Empty"<<endl;
	}
	else if(z=="query"){
    	if(!s.empty()){	
		 cout<<s.top()<<endl;
	    }
    	else cout<<"Anguei!"<<endl;
	}
	else if(z=="size") cout<<s.size()<<endl;
	}}
	return 0;
}
2023/2/5 18:10
加载中...