为什么没法输入啊?
查看原帖
为什么没法输入啊?
999261
songpeiqian楼主2024/9/28 13:22

为什么没法输入啊?

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int N=1000001;
struct Stack{
	int top;
	ULL data[N];
};
bool Is_Empty(Stack &s){
	if(s.top==0) return 1;
	return 0;
}
void Push(Stack &s,ULL tmp){
	s.top++;
	s.data[s.top]=tmp;
}
void Pop(Stack &s){
	if(Is_Empty(s)){
		cout<<"Empty\n";
		return;
	}
	s.top--;
}
void Top(Stack &s){
	if(Is_Empty(s)){
		cout<<"Anguei!\n";
		return;
	}
	cout<<s.data[s.top]<<endl;
}
void Size(Stack &s){
	cout<<s.top<<endl;
}
int t,n;
ULL tmp;
string str;
int main(){
	ios::sync_with_stdio(false);
	cin>>t;
	for(int i=1;i<=t;i++){
		cin>>n;
		Stack s;
		for(int j=1;j<=n;j++){
			cin>>str;
			if(str=="push"){
				cin>>tmp;
				Push(s,tmp);
			}else if(str=="pop"){
				Pop(s);
			}else if(str=="query"){
				Top(s);
			}else if(str=="size"){
				Size(s);
			}
		}
	}
	return 0;
}
2024/9/28 13:22
加载中...