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;
}

posted @ 2012-09-01 16:33  尔滨之夏  阅读(349)  评论(0编辑  收藏  举报