33pts字符串模拟玄关求条
  • 板块B3614 【模板】栈
  • 楼主nAts
  • 当前回复3
  • 已保存回复3
  • 发布时间2024/12/14 09:38
  • 上次更新2024/12/14 11:50:26
查看原帖
33pts字符串模拟玄关求条
819650
nAts楼主2024/12/14 09:38

Code\huge Code

#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
typedef long double ld;
ll t,n,x;
string solve;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>t;
	for(ll i=0;i<t;i++){
		cin>>n;
		string rwr;
		for(ll j=0;j<n;j++){
			cin>>solve;
			if(solve=="push"){
				cin>>x;
				rwr+=(x+'0');
			}
			if(solve=="query"){
				ll len=rwr.size();
				if(len!=0){
					cout<<rwr[len-1]<<"\n";
				}
				else{
					cout<<"Anguei!\n";
				}
			}
			if(solve=="size"){
				ll len=rwr.size();
				cout<<len<<"\n";
			}
			if(solve=="pop"){
				string owo;
				ll len=rwr.size();
				if(len==0){
					cout<<"Empty\n";
				}
				else{
					for(ll k=0;k<len-1;k++){
						owo[k]=rwr[k];
					}
					rwr=owo;
				}
			}
		}
	}
	return 0;
}
2024/12/14 09:38
加载中...