全部评论 3

  • 看不懂的,看下面

    6天前 来自 上海

    1
  • #include<iostream>
    #include<string>
    #include<stack>
    using namespace std;
    int main()
    {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string a;
    while(getline(cin,a))//逐行读取输入
    {
    int aa=-1;
    for(int i=0;i<a.length();i++)
    {
    if(a[i]'@')// 处理退行符@:保留最后一个@之后的内容
    {
    aa=i;
    }
    }
    string b;
    if(aa!=-1)
    {
    b=a.substr(aa+1);
    }
    else
    {
    b=a;
    }
    stack<char>s;// 用栈处理退格符#
    for(int i=0;i<b.length();i++)
    {
    char c=b[i];
    if(c
    '#')
    {
    if(!s.empty())
    {
    s.pop();// 退格,弹出栈顶元素
    }
    }
    else
    {
    s.push(c); // 普通字符入栈
    }
    }
    string bb;
    while(!s.empty())// 从栈中取出结果(栈是后进先出,需要反转)
    {
    bb=s.top()+bb;// 每次在前面添加
    s.pop();
    }
    cout<<bb<<endl;// 输出处理后的结果
    }
    return 0;
    }

    6天前 来自 上海

    1
  • 判断里面都是==

    6天前 来自 上海

    1
首页