解题思路:
注意事项:
参考代码:
#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语言程序设计教程(第三版)课后习题11.1 (C语言代码)浏览:689 |
C语言程序设计教程(第三版)课后习题10.3 (C语言代码)浏览:682 |
C二级辅导-计负均正 (C语言代码)浏览:647 |
2005年春浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:494 |
【亲和数】 (C语言代码)浏览:492 |
上车人数 (C语言代码)浏览:778 |
【亲和数】 (C语言代码)浏览:857 |
WU-输入输出格式练习 (C++代码)浏览:1079 |
WU-陶陶摘苹果2 (C++代码)浏览:970 |
C语言程序设计教程(第三版)课后习题5.6 (C语言代码)浏览:901 |