//就最后一个点错,用string还是错的
#include<bits/stdc++.h> 
using namespace std;
int main()
{
    stack<char>s1,s2;
    string str;
    getline(cin,str);
    for(int i=0;i<str.size();i++)
        switch(str[i])
        {
            case '#':s1.pop();break;
            case '@':while(!s1.empty())s1.pop();break;
            default:s1.push(str[i]);
        }
    while(!s1.empty())
    {
        s2.push(s1.top());
        s1.pop();
    }
    while(!s2.empty())
    {
        cout<<s2.top();
        s2.pop();
    }
    return 0;
}

3 条评论

  • 我觉得是评测及的问题,因为我看金老师AC的记录用的评测机是Jtwd2,而我们都是undefined。

  • 你们测这题是在win10还是win7上,我觉得可能是版本的问题,最后一个测试点中那个问号可能win10的系统不支持。

  • @ 2023-05-21 21:53:28
    //又来一个找茬的
    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
        char s[150];
        int top=0;
        string str;
        getline(cin,str);
        for(int i=0;i<str.size();i++)
            switch(str[i])
            {
                case '#':top--;break;
                case '@':top=0;break;
                default:top++; s[top]=str[i];
            }
        for(int i=1;i<=top;i++)
            cout<<s[i];
        cout<<endl;
    }
    
  • 1

信息

ID
2052
难度
8
分类
(无)
标签
递交数
33
已通过
5
通过率
15%
被复制
6
上传者