故我


私信TA

用户名:uq_37592642929

访问量:1455

签 名:

一起去啊,更远方的地方!!!!

等  级
排  名 735
经  验 3724
参赛次数 0
文章发表 53
年  龄 0
在职情况 学生
学  校 社会大学
专  业

  自我简介:

解题思路:

注意事项:

参考代码:

#include <stdio.h>

#include <string.h>

struct s{

    char data[10000];

    int top;

}n;

void push(char t){

    n.top++;

    n.data[n.top]=t;

    n.data[n.top+1]='\0';

}

void pop(){

    if (n.top==-1){  //栈已经空了,就不操作

        return;

    }

    n.top--;

}

void clean(){

    n.top=-1;

}

void print(){

    puts(n.data);

    n.top=-1;   //输出完记得清空栈

}

int main (){

    char a[10000];

    n.top=-1;

    while (gets(a)!=NULL){

        for (int i=0;a[i]!='\0';i++){

            if (a[i]=='#'){

                pop();

            }else if (a[i]=='@'){

                clean();

            }else {

                push(a[i]);

            }

        }

        print();

    }

}


 

0.0分

0 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换

万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区