行编辑行器

# include <stdio.h>
# include <string.h>
struct node
{
    char a[300];
    int top;
}p;
int main()
{
    char s[1000];
    int i,j,k,n;
    while(gets(s) != NULL)
    {
        p.top=0;
        n=strlen(s);
        for(i=0;i<n;i++)
        {
            if(s[i] != '#' && s[i] != '@')
                p.a[p.top++]=s[i];
            else if(s[i]=='#')
            {
                if(p.top!=0)
                    p.top--;
            }
            else if(s[i] == '@')
                p.top=0;
        }
        for(i=0;i<p.top;i++)
            printf("%c",p.a[i]);
        printf("\n");
    }
    return 0;
}

 

posted on 2013-09-25 18:25  随风浪子的博客  阅读(134)  评论(0编辑  收藏  举报

导航