如何清空!
查看原帖
如何清空!
1244320
Delayed楼主2024/7/31 08:11
#include<bits/stdc++.h>
using namespace std;
stack<unsigned long long int>a;
int t,n[1000005];
int main(){
	cin>>t;
	for(int i=1;i<=t;i++){
		cin>>n[i];
		for(int j=1;j<=n[i];j++){
			string s;
			cin>>s;
			if(s=="push"){
				unsigned long long x;
				cin>>x;
				a.push(x);
			}else if(s=="pop"){
				if(a.empty()){
					cout<<"Empty"<<endl;
					continue;
					
				}else{
					a.pop();
				}
			}else if(s=="query"){
				if(a.empty()){
					cout<<"Anguei!"<<endl;
					continue;
				}else{
					cout<<a.top()<<endl;
				}
			}else if(s=="size"){
				cout<<a.size()<<endl;
			}
		}
		
		memset(n,sizeof(n),0);
	}
	return 0;
}

如何清空!

2024/7/31 08:11
加载中...