#include <bits/stdc++.h>
using namespace std;
stack<char>S;
char str[250], _string[250];
int main()
{
while(gets(_string))
{
int lenth = strlen(_string);
for(int i = 0; i < lenth; i++)
{
if(_string[i] == '#')
{
if(!S.empty())
{
S.pop();
}
}
else if(_string[i] == '@')
{
if(_string[i+1] == '#' && S.empty())
{
continue;
}
else
{
while(!S.empty())
{
S.pop();
}
}
}
else
{
S.push(_string[i]);
}
}
int k = 0;
while(!S.empty())
{
str[++k] = S.top();
S.pop();
}
for(int i = k; i >= 1; i--)
{
cout << str[i];
}
cout << endl;
}
return 0;
}
SDUT 1479 数据结构实验之栈:行编辑器
最新推荐文章于 2020-10-31 15:11:45 发布