33pts求调(数组模拟)
查看原帖
33pts求调(数组模拟)
1219123
Xun_ber7827楼主2024/10/23 22:41
#include<bits/stdc++.h>
using namespace std;
unsigned long long a[1000001]={0};
int main(){
	int m;
	cin>>m;
	for(int i=1;i<=m;i++){
		int n,r=1;
		cin>>n;
		for(int j=1;j<=n;j++){
			a[j]=0;
		}
		for(int j=1;j<=n;j++){
			string x;
			cin>>x;
			if(x[0]=='q'){
				if(r==1) cout<<"Anguei!"<<endl;
				else{
					cout<<a[r-1]<<endl;
				}
			}
			if(x[0]=='s'){
				cout<<r-1<<endl;
			}
			if(x[0]=='p'&&x[1]=='o'){
				if(r==1) cout<<"Empty"<<endl;
			else{
					r--;
				}
			}
			if(x[0]=='p'&&x[1]=='u'){
				int y;
				cin>>y;
				r++;
				a[r-1]=y;
			}
		}
	}
	return 0;
}

rt

2024/10/23 22:41
加载中...