解题思路:
注意事项:
参考代码:
#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 人评分
C语言程序设计教程(第三版)课后习题6.7 (C语言代码)浏览:646 |
简单的a+b (C语言代码)浏览:531 |
C语言程序设计教程(第三版)课后习题3.7 (C语言代码)浏览:842 |
【计算直线的交点数】 (C语言代码)浏览:1453 |
C语言程序设计教程(第三版)课后习题3.7 (C语言代码)浏览:262 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:1072 |
罗列完美数 (C语言代码)浏览:491 |
程序员的表白 (C语言代码)浏览:598 |
排序算法(选择,插入,冒泡)浏览:775 |
C语言程序设计教程(第三版)课后习题5.4 (C语言代码)浏览:468 |