#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#define MAXSIZE 100
#define another 50
#define true 1
#define false 0
#define OVERFLOW -2
using namespace std;
typedef int status;
typedef char elemtype;
//stack
typedef struct
{
elemtype *base;
elemtype *top;
int stacksize;
}Sqstack;
status isEmpty(Sqstack &S)
{
if(S.top == S.base)
return true;
else
return false;
}
status isFull(Sqstack &S)
{
if(S.top - S.base >= MAXSIZE)
return true;
else
return false;
}
void initSqstack(Sqstack &S)
{
S.base = new elemtype[MAXSIZE];
S.top = S.base;
S.stacksize = MAXSIZE;
}
elemtype getTop(Sqstack &S)
{
if(S.top == S.base)
return false;
else
return *(S.top - 1);
}
void Push(Sqstack &S, elemtype e)
{
if(S.top - S.base >= S.stacksize)
{
S.base = (elemtype *)realloc(S.base,
(another + S.stacksize) *sizeof(elemtype));
S.top = S.base + S.stacksize;
S.stacksize += another;
}
*S.top++ = e;
}
int Pop(Sqstack &S, elemtype &e)
{
if(S.top == S.base) return false;
return e = * --S.top;
}
void clear(Sqstack &S)
{
S.base = S.top;
}
//运算符优先级比较
int Cmp(char ch)
{
int flag;
if(ch =='+' || ch == '-')
flag = 1;
else if(ch == '*' || ch == '/')
flag = 2;
else if(ch == '(')
flag = 3;
else if(ch == ')')
flag = 4;
return flag;
}
//转换后缀狮
void change(Sqstack &S, char str[])
{
char ch;
for(int i = 0; str[i] != '#'; i++)
{
if(str[i] >= 'a' && str[i] <= 'z'){
printf("%c", str[i]);
}
else
{
if(isEmpty(S)){
Push(S, str[i]);
}
else if(Cmp(str[i]) > Cmp(getTop(S))){
if(str[i] == ')'){
while(getTop(S) != '('){
printf("%c", getTop(S));
Pop(S, ch);
}
Pop(S, ch);
}
else
Push(S, str[i]);
}
else {
if(getTop(S) != '('){
printf("%c", getTop(S));
Pop(S, ch);
Push(S, str[i]);
}
else
Push(S, str[i]);
}
}
}
while(!isEmpty(S)){
char c;
Pop(S, c);
printf("%c", c);
}
}
// 后缀狮求值
//遇到字母入栈,遇到运算符的时候将栈顶两个元素作运算,元素出栈,运算结果入栈。
// 次顶元素 与栈顶元素 作比较;
void Anser(Sqstack S, char str[])
{
for(int i = 0; str[i] != '#'; i++){
if(str[i] >= '0' && str[i] <= '9'){
Push(S, str[i] - '0');
}
else if(str[i] == '*'){
int a, b;
Pop(S, a);
Pop(S, b);
Push(S, b*a);
}
else if(str[i] == '/'){
int a, b;
Pop(S, a);
Pop(S, b);
Push(S, b/a);
}
else if(str[i] == '+'){
int a, b;
Pop(S, a);
Pop(S, b);
Push(S, b+a);
}
else if(str[i] == '-'){
int a, b;
Pop(S, a);
Pop(S, b);
Push(S, b-a);
}
}
printf("%d\n", getTop(S));
}
//括号匹配
int match(Sqstack &S, char str[])
{
int flag;
for(int i = 0; str[i] != '\0'; i++){
if(str[i] == '(' || str[i] == '{' || str[i] == '['){
flag = true;
Push(S, str[i]);
}
else if(str[i] == ')'){
if(isEmpty(S)){
flag = false;
break;
}
char c = getTop(S);
if(getTop(S) == '('){
Pop(S, c);
flag = true;
}
else{
flag = false;
break;
}
}
else if(str[i] == '}'){
if(isEmpty(S)){
flag = false;
break;
}
char c = getTop(S);
if(getTop(S) == '{'){
Pop(S, c);
flag = true;
}
else{
flag = false;
break;
}
}
else if(str[i] == ']'){
if(isEmpty(S)){
flag = false;
break;
}
char c = getTop(S);
if(getTop(S) == '['){
Pop(S, c);
flag = true;
}
else{
flag = false;
break;
}
}
}
if(!isEmpty(S))
flag = false;
return flag;
}
int main()
{
char str[55];
while(gets(str))
{
Sqstack S;
initSqstack(S);
int flag = match(S, str);
if(flag == true)
printf("yes\n");
else
printf("no\n");
}
Sqstack S;
initSqstack(S);
scanf("%s", str);
change(S, str);
if(n == 0) printf("0\n");
else{
while(n)
{
int cnt = n % r;
Push(S,cnt);
n /= r;
}
while(!isEmpty(S))
{
int cnt = Pop(S, cnt);
printf("%d", cnt);
}
printf("\n");
}
//printf("\n");
char str[100];
Sqstack S;
initSqstack(S);
scanf("%s", str);
Anser(S, str);*/
char str[250];
char ch;
while(gets(str))
{
Sqstack S;
initSqstack(S);
for(int i = 0; i < strlen(str); i++){
if(str[i] == '#'){
if(!isEmpty(S)){
Pop(S, ch);
}
}
else if(str[i] == '@'){
clear(S);
}
else
Push(S, str[i]);
}
int i = 0;
while(!isEmpty(S)){
ch = Pop(S, ch);
str[i++] = ch;
}
for(int j = i-1; j >= 0; j--)
printf("%c", str[j]);
printf("\n");
}
return 0;
}