数组栈coj 1019

好事多磨,百炼方能成钢

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

posted @ 2012-04-10 22:58  月之华  阅读(142)  评论(0编辑  收藏  举报