RE求助,B3614栈
  • 板块学术版
  • 楼主lwx20211103
  • 当前回复7
  • 已保存回复7
  • 发布时间2022/8/10 11:52
  • 上次更新2023/10/27 16:09:19
查看原帖
RE求助,B3614栈
727008
lwx20211103楼主2022/8/10 11:52
#include <bits/stdc++.h>
using namespace std;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t, n;
	int i, j;
	cin >> t;
	for (i = 0; i < t; i++)
	{
		stack<long long> m;
		string s;
		cin >> n;
		for (j = 0; j < n; j++)
		{
			cin >> s;
			if (s == "push")
			{
				long long temp;
				cin >> temp;
				m.push(temp);
			}
			else if (s == "query")
			{
				if (s.empty())
				{
					cout << "Auguei!" << endl;
				}
				else
				{
					cout << m.top() << endl;
				}
			}
			else if (s == "pop")
			{
				if (m.empty())
				{
					cout << "Empty" << endl;
				}
				else m.pop();
			}
			else if (s == "size")
			{
				cout << m.size() << endl;
			}
		}
	}
	return 0;
}

这是我的代码,我尝试看了题解去改,但还是RE了,有人能帮助我吗?

2022/8/10 11:52
加载中...