求助,为什么这段代码会RE?
  • 板块灌水区
  • 楼主chenxi797
  • 当前回复40
  • 已保存回复40
  • 发布时间2024/4/15 20:02
  • 上次更新2024/4/17 22:06:39
查看原帖
求助,为什么这段代码会RE?
735165
chenxi797楼主2024/4/15 20:02
#include <bits/stdc++.h>
using namespace std;
stack <char> st;
char a[25];
int main()
{
    char ch;
    while (cin >> ch)
    {
        if (st.top() == ch) st.pop();
        else st.push(ch);
    }
    int cnt = 0;
    while (!st.empty())
    {
        a[++cnt] = st.top();
        st.pop();
    }
    for (int i = cnt;i >= 1;i--) cout << a[i];
}
2024/4/15 20:02
加载中...