蒟蒻33分,1ac,2re,3wa,手写栈
  • 板块B3614 【模板】栈
  • 楼主isop
  • 当前回复2
  • 已保存回复2
  • 发布时间2023/12/23 10:50
  • 上次更新2023/12/23 13:05:33
查看原帖
蒟蒻33分,1ac,2re,3wa,手写栈
1071516
isop楼主2023/12/23 10:50
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	string str;
	int a,b;
	cin>>a;
	for(int i=1;i<=a;i++)
	{
        cin>>b;
        unsigned long long int stk[100010];
        int top=0;
		for(int j=1;j<=b;j++)
		{
            cin>>str;
			if (str == "push") 
			{
				int x;
				cin >> x;
				stk[++top]=x;
			} 
			else if (str == "pop") 
			{
				if (top==0) 
				    cout << "Empty\n";	
                else
                    top--;		
			} 
			else if (str == "query")
			{
	        	if (top==0) 
					cout << "Anguei!\n";
	        	else 
					cout<<stk[top]<<endl;
			} 
			else
			{
	        	cout<<top<<endl;
	    	}
		}
	}
}
2023/12/23 10:50
加载中...