好事多磨,百炼方能成钢
#include<stdio.h>
#include<string.h>
#include<ctype.h>
#define MAXN 10000
char a[MAXN];
char b[MAXN];
int main()
{
int i, T, top, len;
scanf("%d\n",&T);
while(T)
{
--T;
gets(a);
len = strlen(a);
top = -1;
for(i = 0; i < len; i++)
{
if(isalpha(a[i])) b[++top] = a[i];
else if(a[i] == '#'&&top >= 0) --top;
else if(a[i] == '@'&&top >= 0) top = -1;
}
for(i = 0; i <= top; i++) printf("%c",b[i]);
printf("\n");
}
return 0;
}