提交时间:2024-04-06 09:05:16

运行 ID: 141621

#include <bits/stdc++.h> using namespace std; int main() { string ans, t; cin >> t; for (int i = 0; i < t.size(); i++) { ans += t[i]; if (t[i] == '#') ans.replace(ans.size() - 2, 2, ""); else if (t[i] == '@') { for (int j = ans.size() - 1; j >= 0; j--) if (j == ' ') break; else ans.replace(j - 1, 1, ""); } } cout << ans << endl; return 0; }