jiandan
2025-02-16 11:05:12
发布于:贵州
40阅读
0回复
0点赞
#include <bits/stdc++.h>
using namespace std;
int idx;
char s[1010];//栈数组
string str;//读入的字符串
void push(char x){
s[++ idx] = x;
}
void pop(){
idx --;
}
int main(){
while(getline(cin, str)){//多组输入有空格的字符串
if(str == "******") break;
for(auto it : str){
//当前元素是it
if(it == '#'){//退一格
if(idx > 0) idx --;
}else if(it == '@') idx = 0;
else push(it);
}
for(int i = 1; i <= idx; i ++ ){
cout << s[i];
}
cout << endl;
idx = 0;
}
return 0;
}
这里空空如也
有帮助,赞一个