66pts求调
查看原帖
66pts求调
1282570
zxChicken4088楼主2025/2/7 19:49
#include <iostream>
#include <stack>
using namespace std;
using ull = unsigned long long;

int t, n;
stack<ull> st;

int main()
{
	cin >> t;
	while (t--)
	{
		cin >> n;
		while (n--)
		{
			string s; cin >> s;
			if (s == "push")
			{
				ull x; cin >> x;
				st.push(x);
			}
			else if (s == "pop")
			{
				if (st.empty()) cout << "Empty" << endl;
				else st.pop();
			}
			else if (s == "size") cout << st.size() << endl;
			else
			{
				if (st.empty()) cout << "Anguei!" << endl;
				else cout << st.top() << endl;
			}
		}
	}
 	return 0;
}

我用的 STL 别喷。

2025/2/7 19:49
加载中...