Simple Line Editor Time Limit: 1000 MS Memory Limit: 65536 K Total Submit: 250(49 users) Total Accepted: 74(42 users) Special Judge: No Description
#include<stdio.h>
#include<string.h>
int main()
{
int n,i,len,j;
char a[1000],b[1000],top,g,t;
while(scanf("%d",&n)!=EOF)
for(i=0;i<n;i++)
{
scanf("%s",a);
len=strlen(a);
top=0;
g=-1;
for(j=len-1;j>=0;j--)
if(a[j]=='@')
{
g=j;
break;
}
for(j=g+1;j<len;j++)
{
if(a[j]!='#')
{
b[top++]=a[j];
}
else
{
if(top!=0)
--top;
}
}
for(j=0;j<top;j++)
printf("%c",b[j]);
printf("\n");
}
return 0;
}