行编辑器

来源:互联网 发布:怎样手机发布淘宝微淘 编辑:程序博客网 时间:2024/05/05 04:59
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct
{
    char *num;
    int top;
}sq;


void st(sq &l,int e)
{
    l.num=(char *)malloc(1000*sizeof(char));
    l.top=0;
}
void push(sq &l,int e)
{
    l.num[l.top]=e;
    l.top++;
}
void pop(sq &l)
{
    l.top--;
    printf("%c",l.num[l.top]);


}


int main()
{
    sq l;
    char a[1000];
    int i,j,n,e,m;


    while(gets(a)!=NULL)
    {


         n=strlen(a);
         st(l,n);
        for(i=0;i<n;i++)
        {
            if(a[i]=='#')
            {
                    if(l.top!=0)
                    {
                        l.top--;
                    }
            }
            else if(a[i]=='@')
            {
                l.top=0;
            }
            else
            {
                push(l,a[i]);
            }
        }
        for(int j=0;j<l.top;j++)
        {
            printf("%c",l.num[j]);
        }
        printf("\n");


    }
    return 0;
}






/**************************************
Problem id : SDUT OJ C 
User name : wy150318王鹏鹏 
Result : Accepted 
Take Memory : 224K 
Take Time : 0MS 
Submit Time : 2016-07-30 15:05:57  
**************************************/
0 0