不是我手工栈招谁惹谁了只有33……
查看原帖
不是我手工栈招谁惹谁了只有33……
1612650
Aya_ylxatch楼主2025/1/24 23:54
#include<iostream> 
using namespace std;
typedef unsigned long long ULL;
const int N=1e6+5;
string s;
ULL t,n,x,sk[N],top=0;
int main(){
	scanf("%lld",&t);
	while(t--){
		scanf("%lld",&n);
		while(n--){
			cin>>s;
			if(s=="push"){
				scanf("%lld",&x);
				sk[++top]=x;
			}else if(s=="pop"){
				if(top)top--;
				else puts("Empty");
			}else if(s=="query"){
				if(top)printf("%lld\n",sk[top]);
				else puts("Anguei!");
			}else{
				printf("%lld\n",top);
			}
		}top=0;
	}
	return 0;
}
2025/1/24 23:54
加载中...