提交时间:2024-04-06 08:42:43
运行 ID: 141592
#include <iostream> #include <stack> #include <string> using namespace std; stack <char> a; string res; int main() { string s; getline(cin, s); int len = s.size(); for(int i = 0; i < len; i++) { if(s[i] == '@') while(!a.empty()) a.pop(); else if(s[i] == '#') if(!a.empty()) a.pop(); else a.push(s[i]); } int cur = 0; while(!a.empty()) { res[++cur] = a.top(); a.pop(); } for(int i = cur; i >= 1; i--) cout << res[i]; cout << endl; return 0; }