#include<iostream>
using namespace std;
struct Stack
{
char a;
Stack *next;
};
class UsSta
{
private:
Stack *top,*base;
public:
UsSta()
{
top = new Stack;
base = new Stack;
top->next = base;
base->next = NULL;
}
~UsSta()
{
delete top;
delete base;
}
void AddSta(char b)
{
Stack *p1 = new Stack;
p1->a = b;
p1->next = top->next;
top->next = p1;
}
void DelSta()
{
top->next = top->next->next;
}
void VoiSta()
{
top->next = base;
}
void UseSta(char b[100])
{
int i = 0;
while(b[i])
{
if(b[i] == '#')
{
DelSta();
}
else if(b[i] == '@')
{
VoiSta();
}
else
{
AddSta(b[i]);
}
i++;
}
}
void PriSta()
{
char e[100];
int i = 0;
Stack *p1 = top->next;
while(p1->next != NULL)
{
e[i] = p1->a;
p1 = p1->next;
i++;
}
do
{
i--;
cout <<e[i];
}while(i);
cout <<endl;
}
};
int main()
{
UsSta Us;
char h[100];
while(gets(h))
{
Us.UseSta(h);
Us.PriSta();
Us.VoiSta();
}
}
/**************************************************************
Problem: 2143
User: admin
Language: C++
Result: Accepted
Time:14 ms
Memory:2076 kb
****************************************************************/