提交时间:2023-12-30 21:43:48

运行 ID: 118562

#include<bits/stdc++.h> using namespace std; stack <char> stk; int main(){ string s; getline(cin,s); for (int i = 0;i < s.size();i++){ char x = s[i]; if (x == '#' && !stk.empty()){ stk.pop(); } else if (x == '@'){ while (!stk.empty()){ stk.pop(); } } else if (x != '#' && x != '@'){ stk.push(x); } } deque <char> q; while (!stk.empty()){ //putchar(stk.top()); q.push_back(stk.top()); stk.pop(); } while (!q.empty()){ putchar(q.back()); q.pop_back(); } return 0; }