稻花香里说丰年,听取RE声一片
查看原帖
稻花香里说丰年,听取RE声一片
922137
Mark_Zhu楼主2023/8/30 22:45
#include<bits/stdc++.h>
using namespace std;
struct stack{
	unsigned long long tp,a[1000005];
	void clear(){
		tp=0;
	}
	void push(unsigned long long x){
		a[++tp]=x;
	}
	void pop(){
		tp--;
	}
	int size(){
		return tp;
	}
	int top(){
		return a[tp];
	}
	bool empty(){
		return tp==0;
	}
}s;
int main(){
	string st;
	unsigned long long x,t,n;
	scanf("%d",&t);
	for(int i=0;i<t;i++){
		scanf("%d",&n);
		for(int i=0;i<n;i++){
			scanf("%s",&st);
			if(st=="push"){
				scanf("%d",&x);
				s.push(x);
			}
			if(st=="query")
				if(s.empty())printf("Anguei!\n");
				else printf("%d\n",s.top());
			if(st=="pop")
				if(s.empty())printf("Empty\n");
				else s.pop();
			if(st=="size")printf("%d",s.size());
		}
	}
	return 0;
}

为啥不对??????????

2023/8/30 22:45
加载中...