社区讨论
RE求助,B3614栈
学术版参与者 4已保存回复 7
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 7 条
- 当前快照
- 1 份
- 快照标识符
- @lo8c14ct
- 此快照首次捕获于
- 2023/10/27 16:09 2 年前
- 此快照最后确认于
- 2023/10/27 16:09 2 年前
CPP
#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了,有人能帮助我吗?
回复
共 7 条回复,欢迎继续交流。
正在加载回复...